Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-swarm
Commits
f4b401f2
Commit
f4b401f2
authored
Apr 14, 2021
by
Cory Schwartz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests after merge
parent
f0aa4f29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
dial_test.go
dial_test.go
+23
-4
No files found.
dial_test.go
View file @
f4b401f2
...
@@ -583,6 +583,7 @@ func TestDialSimultaneousJoin(t *testing.T) {
...
@@ -583,6 +583,7 @@ func TestDialSimultaneousJoin(t *testing.T) {
go
acceptAndHang
(
s2silentListener
)
go
acceptAndHang
(
s2silentListener
)
connch
:=
make
(
chan
network
.
Conn
,
512
)
connch
:=
make
(
chan
network
.
Conn
,
512
)
errs
:=
make
(
chan
error
,
2
)
// start a dial to s2 through the silent addr
// start a dial to s2 through the silent addr
go
func
()
{
go
func
()
{
...
@@ -590,12 +591,15 @@ func TestDialSimultaneousJoin(t *testing.T) {
...
@@ -590,12 +591,15 @@ func TestDialSimultaneousJoin(t *testing.T) {
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
errs
<-
err
connch
<-
nil
return
}
}
t
.
Logf
(
"first dial succedded; conn: %+v"
,
c
)
t
.
Logf
(
"first dial succedded; conn: %+v"
,
c
)
connch
<-
c
connch
<-
c
errs
<-
nil
}()
}()
// wait a bit for the dial to take hold
// wait a bit for the dial to take hold
...
@@ -605,18 +609,22 @@ func TestDialSimultaneousJoin(t *testing.T) {
...
@@ -605,18 +609,22 @@ func TestDialSimultaneousJoin(t *testing.T) {
go
func
()
{
go
func
()
{
s2addrs
,
err
:=
s2
.
InterfaceListenAddresses
()
s2addrs
,
err
:=
s2
.
InterfaceListenAddresses
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
errs
<-
err
return
}
}
s1
.
Peerstore
()
.
AddAddrs
(
s2
.
LocalPeer
(),
s2addrs
[
:
1
],
peerstore
.
PermanentAddrTTL
)
s1
.
Peerstore
()
.
AddAddrs
(
s2
.
LocalPeer
(),
s2addrs
[
:
1
],
peerstore
.
PermanentAddrTTL
)
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
errs
<-
err
connch
<-
nil
return
}
}
t
.
Logf
(
"second dial succedded; conn: %+v"
,
c
)
t
.
Logf
(
"second dial succedded; conn: %+v"
,
c
)
connch
<-
c
connch
<-
c
errs
<-
nil
}()
}()
// wait for the second dial to finish
// wait for the second dial to finish
...
@@ -626,16 +634,27 @@ func TestDialSimultaneousJoin(t *testing.T) {
...
@@ -626,16 +634,27 @@ func TestDialSimultaneousJoin(t *testing.T) {
go
func
()
{
go
func
()
{
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
c
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
errs
<-
err
connch
<-
nil
return
}
}
t
.
Logf
(
"third dial succedded; conn: %+v"
,
c
)
t
.
Logf
(
"third dial succedded; conn: %+v"
,
c
)
connch
<-
c
connch
<-
c
errs
<-
nil
}()
}()
c3
:=
<-
connch
c3
:=
<-
connch
// raise any errors from the two
for
i
:=
0
;
i
<
3
;
i
++
{
err
:=
<-
errs
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
if
c2
!=
c3
{
if
c2
!=
c3
{
t
.
Fatal
(
"expected c2 and c3 to be the same"
)
t
.
Fatal
(
"expected c2 and c3 to be the same"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment