Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
b4e4d496
Commit
b4e4d496
authored
Sep 18, 2018
by
Can ZHANG
Browse files
Fix test
parent
d859fb0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/protocol/identify/obsaddr_test.go
View file @
b4e4d496
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"testing"
"testing"
"time"
"time"
net
"github.com/libp2p/go-libp2p-net"
ma
"github.com/multiformats/go-multiaddr"
ma
"github.com/multiformats/go-multiaddr"
)
)
...
@@ -49,15 +50,22 @@ func TestObsAddrSet(t *testing.T) {
...
@@ -49,15 +50,22 @@ func TestObsAddrSet(t *testing.T) {
b4
:=
m
(
"/ip4/1.2.3.9/tcp/1237"
)
b4
:=
m
(
"/ip4/1.2.3.9/tcp/1237"
)
b5
:=
m
(
"/ip4/1.2.3.10/tcp/1237"
)
b5
:=
m
(
"/ip4/1.2.3.10/tcp/1237"
)
oas
:=
ObservedAddrSet
{}
oas
:=
&
ObservedAddrSet
{}
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
t
.
Error
(
"addrs should be empty"
)
t
.
Error
(
"addrs should be empty"
)
}
}
oas
.
Add
(
a1
,
a4
)
add
:=
func
(
oas
*
ObservedAddrSet
,
observed
,
observer
ma
.
Multiaddr
)
{
oas
.
Add
(
a2
,
a4
)
dummyLocal
:=
m
(
"/ip4/127.0.0.1/tcp/10086"
)
oas
.
Add
(
a3
,
a4
)
dummyDirection
:=
net
.
DirOutbound
oas
.
Add
(
observed
,
dummyLocal
,
observer
,
dummyDirection
)
}
add
(
oas
,
a1
,
a4
)
add
(
oas
,
a2
,
a4
)
add
(
oas
,
a3
,
a4
)
// these are all different so we should not yet get them.
// these are all different so we should not yet get them.
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
...
@@ -65,39 +73,39 @@ func TestObsAddrSet(t *testing.T) {
...
@@ -65,39 +73,39 @@ func TestObsAddrSet(t *testing.T) {
}
}
// same observer, so should not yet get them.
// same observer, so should not yet get them.
oas
.
Add
(
a1
,
a4
)
add
(
oas
,
a1
,
a4
)
oas
.
Add
(
a2
,
a4
)
add
(
oas
,
a2
,
a4
)
oas
.
Add
(
a3
,
a4
)
add
(
oas
,
a3
,
a4
)
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
t
.
Error
(
"addrs should _still_ be empty (same obs)"
)
t
.
Error
(
"addrs should _still_ be empty (same obs)"
)
}
}
// different observer, but same observer group.
// different observer, but same observer group.
oas
.
Add
(
a1
,
a5
)
add
(
oas
,
a1
,
a5
)
oas
.
Add
(
a2
,
a5
)
add
(
oas
,
a2
,
a5
)
oas
.
Add
(
a3
,
a5
)
add
(
oas
,
a3
,
a5
)
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
if
!
addrsMarch
(
oas
.
Addrs
(),
nil
)
{
t
.
Error
(
"addrs should _still_ be empty (same obs group)"
)
t
.
Error
(
"addrs should _still_ be empty (same obs group)"
)
}
}
oas
.
Add
(
a1
,
b1
)
add
(
oas
,
a1
,
b1
)
oas
.
Add
(
a1
,
b2
)
add
(
oas
,
a1
,
b2
)
oas
.
Add
(
a1
,
b3
)
add
(
oas
,
a1
,
b3
)
if
!
addrsMarch
(
oas
.
Addrs
(),
[]
ma
.
Multiaddr
{
a1
})
{
if
!
addrsMarch
(
oas
.
Addrs
(),
[]
ma
.
Multiaddr
{
a1
})
{
t
.
Error
(
"addrs should only have a1"
)
t
.
Error
(
"addrs should only have a1"
)
}
}
oas
.
Add
(
a2
,
a5
)
add
(
oas
,
a2
,
a5
)
oas
.
Add
(
a1
,
a5
)
add
(
oas
,
a1
,
a5
)
oas
.
Add
(
a1
,
a5
)
add
(
oas
,
a1
,
a5
)
oas
.
Add
(
a2
,
b1
)
add
(
oas
,
a2
,
b1
)
oas
.
Add
(
a1
,
b1
)
add
(
oas
,
a1
,
b1
)
oas
.
Add
(
a1
,
b1
)
add
(
oas
,
a1
,
b1
)
oas
.
Add
(
a2
,
b2
)
add
(
oas
,
a2
,
b2
)
oas
.
Add
(
a1
,
b2
)
add
(
oas
,
a1
,
b2
)
oas
.
Add
(
a1
,
b2
)
add
(
oas
,
a1
,
b2
)
oas
.
Add
(
a2
,
b4
)
add
(
oas
,
a2
,
b4
)
oas
.
Add
(
a2
,
b5
)
add
(
oas
,
a2
,
b5
)
if
!
addrsMarch
(
oas
.
Addrs
(),
[]
ma
.
Multiaddr
{
a1
,
a2
})
{
if
!
addrsMarch
(
oas
.
Addrs
(),
[]
ma
.
Multiaddr
{
a1
,
a2
})
{
t
.
Error
(
"addrs should only have a1, a2"
)
t
.
Error
(
"addrs should only have a1, a2"
)
}
}
...
...
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