diff --git a/p2p/net/gostream/gostream_test.go b/p2p/net/gostream/gostream_test.go index 60d20f57b4..d2e6937c9e 100644 --- a/p2p/net/gostream/gostream_test.go +++ b/p2p/net/gostream/gostream_test.go @@ -7,50 +7,24 @@ import ( "testing" "time" - crypto "github.com/libp2p/go-libp2p-crypto" + libp2p "github.com/libp2p/go-libp2p" host "github.com/libp2p/go-libp2p-host" - peer "github.com/libp2p/go-libp2p-peer" peerstore "github.com/libp2p/go-libp2p-peerstore" protocol "github.com/libp2p/go-libp2p-protocol" - swarm "github.com/libp2p/go-libp2p-swarm" - bhost "github.com/libp2p/go-libp2p/p2p/host/basic" multiaddr "github.com/multiformats/go-multiaddr" ) // newHost illustrates how to build a libp2p host with secio using // a randomly generated key-pair func newHost(t *testing.T, listen multiaddr.Multiaddr) host.Host { - priv, pub, err := crypto.GenerateKeyPair(crypto.RSA, 2048) - if err != nil { - t.Fatal(err) - } - pid, err := peer.IDFromPublicKey(pub) - if err != nil { - t.Fatal(err) - } - ps := peerstore.NewPeerstore() - err = ps.AddPubKey(pid, pub) - if err != nil { - t.Fatal(err) - } - err = ps.AddPrivKey(pid, priv) - if err != nil { - t.Fatal(err) - } - - network, err := swarm.NewNetwork( + h, err := libp2p.New( context.Background(), - []multiaddr.Multiaddr{listen}, - pid, - ps, - nil) - + libp2p.ListenAddrs(listen), + ) if err != nil { t.Fatal(err) } - - host := bhost.New(network) - return host + return h } func TestServerClient(t *testing.T) {