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-kad-dht
Commits
59321226
Unverified
Commit
59321226
authored
Apr 29, 2021
by
Steven Allen
Committed by
GitHub
Apr 29, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #714 from libp2p/fix/uniq-addr
test: fix unique addr check
parents
2a8c43b2
e19b2b82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
dual/dual_test.go
dual/dual_test.go
+12
-5
No files found.
dual/dual_test.go
View file @
59321226
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
record
"github.com/libp2p/go-libp2p-record"
record
"github.com/libp2p/go-libp2p-record"
swarmt
"github.com/libp2p/go-libp2p-swarm/testing"
swarmt
"github.com/libp2p/go-libp2p-swarm/testing"
bhost
"github.com/libp2p/go-libp2p/p2p/host/basic"
bhost
"github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/multiformats/go-multiaddr"
)
)
var
wancid
,
lancid
cid
.
Cid
var
wancid
,
lancid
cid
.
Cid
...
@@ -356,14 +357,20 @@ func TestFindPeer(t *testing.T) {
...
@@ -356,14 +357,20 @@ func TestFindPeer(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
len
(
p
.
Addrs
)
!=
1
{
assertUniqueMultiaddrs
(
t
,
p
.
Addrs
)
t
.
Fatalf
(
"expeced find peer to find 1 address, found %d"
,
len
(
p
.
Addrs
))
}
p
,
err
=
d
.
FindPeer
(
ctx
,
wan
.
PeerID
())
p
,
err
=
d
.
FindPeer
(
ctx
,
wan
.
PeerID
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
len
(
p
.
Addrs
)
!=
1
{
assertUniqueMultiaddrs
(
t
,
p
.
Addrs
)
t
.
Fatalf
(
"expeced find peer to find addresses, found %d"
,
len
(
p
.
Addrs
))
}
func
assertUniqueMultiaddrs
(
t
*
testing
.
T
,
addrs
[]
multiaddr
.
Multiaddr
)
{
set
:=
make
(
map
[
string
]
bool
)
for
_
,
addr
:=
range
addrs
{
if
set
[
string
(
addr
.
Bytes
())]
{
t
.
Errorf
(
"duplicate address %s"
,
addr
)
}
set
[
string
(
addr
.
Bytes
())]
=
true
}
}
}
}
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