Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests #995

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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