Skip to content

Commit

Permalink
Merge pull request #7 from hsanjuan/update/libp2p
Browse files Browse the repository at this point in the history
gx publish 0.0.10
  • Loading branch information
hsanjuan authored Jun 27, 2018
2 parents 5fc7f01 + 9b46b6e commit 28997d8
Showing 1 changed file with 5 additions and 31 deletions.
36 changes: 5 additions & 31 deletions p2p/net/gostream/gostream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 28997d8

Please sign in to comment.