Commit ee69383c authored by vyzo's avatar vyzo
Browse files

extend autorelay test to verify connectivity

parent b62c83bd
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore" pstore "github.com/libp2p/go-libp2p-peerstore"
routing "github.com/libp2p/go-libp2p-routing" routing "github.com/libp2p/go-libp2p-routing"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net" manet "github.com/multiformats/go-multiaddr-net"
) )
...@@ -150,10 +151,12 @@ func TestAutoRelay(t *testing.T) { ...@@ -150,10 +151,12 @@ func TestAutoRelay(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
h4, err := libp2p.New(ctx, libp2p.EnableRelay())
connect(t, h1, h3) connect(t, h1, h3)
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
// verify that we advertise relay addrs
haveRelay := false haveRelay := false
for _, addr := range h3.Addrs() { for _, addr := range h3.Addrs() {
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT) _, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
...@@ -166,4 +169,18 @@ func TestAutoRelay(t *testing.T) { ...@@ -166,4 +169,18 @@ func TestAutoRelay(t *testing.T) {
if !haveRelay { if !haveRelay {
t.Fatal("No relay addrs advertised") 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)
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment