Skip to content

Commit

Permalink
Merge pull request #995 from libp2p/fix/tests
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
Stebalien authored Aug 19, 2020
2 parents 6b509be + de10591 commit 35c2dbd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion p2p/host/relay/autorelay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package relay_test
import (
"context"
"net"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions p2p/protocol/identify/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {})
}
Expand Down Expand Up @@ -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) {})
}
Expand Down

0 comments on commit 35c2dbd

Please sign in to comment.