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
12a0cdb7
Commit
12a0cdb7
authored
Mar 31, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TestDialExistingConnection
parent
0fc0ade2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
dial_test.go
dial_test.go
+26
-0
No files found.
dial_test.go
View file @
12a0cdb7
...
...
@@ -524,3 +524,29 @@ func TestDialPeerFailed(t *testing.T) {
t
.
Errorf
(
"expected %d errors, got %d"
,
expectedErrorsCount
,
len
(
dialErr
.
DialErrors
))
}
}
func
TestDialExistingConnection
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
swarms
:=
makeSwarms
(
ctx
,
t
,
2
)
defer
closeSwarms
(
swarms
)
s1
:=
swarms
[
0
]
s2
:=
swarms
[
1
]
s1
.
Peerstore
()
.
AddAddrs
(
s2
.
LocalPeer
(),
s2
.
ListenAddresses
(),
peerstore
.
PermanentAddrTTL
)
c1
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
c2
,
err
:=
s1
.
DialPeer
(
ctx
,
s2
.
LocalPeer
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
c1
!=
c2
{
t
.
Fatal
(
"expecting the same connection from both dials"
)
}
}
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