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
ee69383c
Commit
ee69383c
authored
Oct 20, 2018
by
vyzo
Browse files
extend autorelay test to verify connectivity
parent
b62c83bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/host/relay/autorelay_test.go
View file @
ee69383c
...
...
@@ -21,6 +21,7 @@ import (
peer
"github.com/libp2p/go-libp2p-peer"
pstore
"github.com/libp2p/go-libp2p-peerstore"
routing
"github.com/libp2p/go-libp2p-routing"
ma
"github.com/multiformats/go-multiaddr"
manet
"github.com/multiformats/go-multiaddr-net"
)
...
...
@@ -150,10 +151,12 @@ func TestAutoRelay(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
h4
,
err
:=
libp2p
.
New
(
ctx
,
libp2p
.
EnableRelay
())
connect
(
t
,
h1
,
h3
)
time
.
Sleep
(
3
*
time
.
Second
)
// verify that we advertise relay addrs
haveRelay
:=
false
for
_
,
addr
:=
range
h3
.
Addrs
()
{
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
...
...
@@ -166,4 +169,18 @@ func TestAutoRelay(t *testing.T) {
if
!
haveRelay
{
t
.
Fatal
(
"No relay addrs advertised"
)
}
// check that we can connect through the relay
var
raddrs
[]
ma
.
Multiaddr
for
_
,
addr
:=
range
h3
.
Addrs
()
{
_
,
err
:=
addr
.
ValueForProtocol
(
circuit
.
P_CIRCUIT
)
if
err
!=
nil
{
raddrs
=
append
(
raddrs
,
addr
)
}
}
err
=
h4
.
Connect
(
ctx
,
pstore
.
PeerInfo
{
h3
.
ID
(),
raddrs
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
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