Steven Allen
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
19 additions and
3 deletions
-
p2p/host/relay/autorelay_test.go
-
p2p/protocol/identify/id_test.go
|
|
@ -3,6 +3,7 @@ package relay_test |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"net" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
@ -132,7 +133,22 @@ func TestAutoRelay(t *testing.T) { |
|
|
|
if err != nil { |
|
|
|
t.Fatal(err) |
|
|
|
} |
|
|
|
_, err = libp2p.New(ctx, libp2p.EnableRelay(circuit.OptHop), libp2p.EnableAutoRelay(), libp2p.Routing(makeRouting)) |
|
|
|
// announce dns addrs because filter out private addresses from relays,
|
|
|
|
// and we consider dns addresses "public".
|
|
|
|
_, err = libp2p.New(ctx, |
|
|
|
libp2p.EnableRelay(circuit.OptHop), |
|
|
|
libp2p.EnableAutoRelay(), |
|
|
|
libp2p.Routing(makeRouting), |
|
|
|
libp2p.AddrsFactory(func(addrs []ma.Multiaddr) []ma.Multiaddr { |
|
|
|
for i, addr := range addrs { |
|
|
|
saddr := addr.String() |
|
|
|
if strings.HasPrefix(saddr, "/ip4/127.0.0.1/") { |
|
|
|
addrNoIP := strings.TrimPrefix(saddr, "/ip4/127.0.0.1") |
|
|
|
addrs[i] = ma.StringCast("/dns4/localhost" + addrNoIP) |
|
|
|
} |
|
|
|
} |
|
|
|
return addrs |
|
|
|
})) |
|
|
|
if err != nil { |
|
|
|
t.Fatal(err) |
|
|
|
} |
|
|
|
|
|
@ -788,7 +788,7 @@ func TestLargeIdentifyMessage(t *testing.T) { |
|
|
|
// add protocol strings to make the message larger
|
|
|
|
// about 2K of protocol strings
|
|
|
|
for i := 0; i < 500; i++ { |
|
|
|
r := "rand" + string(i) |
|
|
|
r := fmt.Sprintf("rand%d", i) |
|
|
|
h1.SetStreamHandler(protocol.ID(r), func(network.Stream) {}) |
|
|
|
h2.SetStreamHandler(protocol.ID(r), func(network.Stream) {}) |
|
|
|
} |
|
|
@ -898,7 +898,7 @@ func TestLargePushMessage(t *testing.T) { |
|
|
|
// add protocol strings to make the message larger
|
|
|
|
// about 2K of protocol strings
|
|
|
|
for i := 0; i < 500; i++ { |
|
|
|
r := "rand" + string(i) |
|
|
|
r := fmt.Sprintf("rand%d", i) |
|
|
|
h1.SetStreamHandler(protocol.ID(r), func(network.Stream) {}) |
|
|
|
h2.SetStreamHandler(protocol.ID(r), func(network.Stream) {}) |
|
|
|
} |
|
|
|