don't use a separate Go module for the autonat tests
This commit is contained in:
parent
741348ec9c
commit
5eeba536ea
|
@ -1,53 +1,40 @@
|
||||||
//go:build ignore
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// This separate testing package helps to resolve a circular dependency potentially
|
// This separate testing package helps to resolve a circular dependency potentially
|
||||||
// being created between libp2p and libp2p-autonat
|
// being created between libp2p and libp2p-autonat
|
||||||
package autonat_test
|
package autonattest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/event"
|
||||||
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/event"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAutonatRoundtrip(t *testing.T) {
|
func TestAutonatRoundtrip(t *testing.T) {
|
||||||
t.Skip("this test doesn't work")
|
t.Skip("this test doesn't work")
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// 3 hosts are used: [client] and [service + dialback dialer]
|
// 3 hosts are used: [client] and [service + dialback dialer]
|
||||||
client, err := libp2p.New(ctx, libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"), libp2p.EnableNATService())
|
client, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"), libp2p.EnableNATService())
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Fatal(err)
|
service, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
}
|
require.NoError(t, err)
|
||||||
service, err := libp2p.New(ctx, libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
dialback, err := libp2p.New(libp2p.NoListenAddrs)
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
dialback, err := libp2p.New(ctx, libp2p.NoListenAddrs)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if _, err := autonat.New(service, autonat.EnableService(dialback.Network())); err != nil {
|
if _, err := autonat.New(service, autonat.EnableService(dialback.Network())); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Peerstore().AddAddrs(service.ID(), service.Addrs(), time.Hour)
|
client.Peerstore().AddAddrs(service.ID(), service.Addrs(), time.Hour)
|
||||||
if err := client.Connect(ctx, service.Peerstore().PeerInfo(service.ID())); err != nil {
|
require.NoError(t, client.Connect(context.Background(), service.Peerstore().PeerInfo(service.ID())))
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cSub, err := client.EventBus().Subscribe(new(event.EvtLocalReachabilityChanged))
|
cSub, err := client.EventBus().Subscribe(new(event.EvtLocalReachabilityChanged))
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer cSub.Close()
|
defer cSub.Close()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package autonat_test
|
package autonattest
|
||||||
|
|
||||||
// needed so that go test ./... doesn't error
|
// needed so that go test ./... doesn't error
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
module github.com/libp2p/go-libp2p-autonat/test
|
|
||||||
|
|
||||||
go 1.16
|
|
||||||
|
|
||||||
replace github.com/libp2p/go-libp2p-autonat => ../
|
|
Loading…
Reference in New Issue