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
69144bd7
Commit
69144bd7
authored
Oct 26, 2018
by
vyzo
Browse files
extend autorelay test to verify pushing of relay addrs
also check that we don't initially advertise any.
parent
0dfca3ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/host/relay/autorelay_test.go
View file @
69144bd7
...
...
@@ -152,16 +152,33 @@ func TestAutoRelay(t *testing.T) {
}
h4
,
err
:=
libp2p
.
New
(
ctx
,
libp2p
.
EnableRelay
())
// verify that we don't advertise relay addrs initially
for
_
,
addr
:=
range
h3
.
Addrs
()
{
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
if
err
==
nil
{
t
.
Fatal
(
"relay addr advertised before auto detection"
)
}
}
// connect to AutoNAT and let detection/discovery work its magic
connect
(
t
,
h1
,
h3
)
time
.
Sleep
(
3
*
time
.
Second
)
// verify that we advertise relay addrs
// verify that we now advertise relay addrs (but not unspecific relay addrs)
unspecificRelay
,
err
:=
ma
.
NewMultiaddr
(
"/p2p-circuit"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
haveRelay
:=
false
for
_
,
addr
:=
range
h3
.
Addrs
()
{
if
addr
.
Equal
(
unspecificRelay
)
{
t
.
Fatal
(
"unspecific relay addr advertised"
)
}
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
if
err
==
nil
{
haveRelay
=
true
break
}
}
...
...
@@ -169,7 +186,7 @@ func TestAutoRelay(t *testing.T) {
t
.
Fatal
(
"No relay addrs advertised"
)
}
//
check
that we can connect through the relay
//
verify
that we can connect through the relay
var
raddrs
[]
ma
.
Multiaddr
for
_
,
addr
:=
range
h3
.
Addrs
()
{
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
...
...
@@ -182,4 +199,21 @@ func TestAutoRelay(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// verify that we have pushed relay addrs to connected peers
haveRelay
=
false
for
_
,
addr
:=
range
h1
.
Peerstore
()
.
Addrs
(
h3
.
ID
())
{
if
addr
.
Equal
(
unspecificRelay
)
{
t
.
Fatal
(
"unspecific relay addr advertised"
)
}
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
if
err
==
nil
{
haveRelay
=
true
}
}
if
!
haveRelay
{
t
.
Fatal
(
"No relay addrs pushed"
)
}
}
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