Commit f61f242f authored by Jeromy's avatar Jeromy
Browse files

Extract netutil to its own package

parent 5a2b58bc
...@@ -5,8 +5,10 @@ import ( ...@@ -5,8 +5,10 @@ import (
"testing" "testing"
"time" "time"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
netutil "github.com/libp2p/go-libp2p/p2p/test/util" netutil "github.com/libp2p/go-libp2p-netutil"
pstore "github.com/libp2p/go-libp2p-peerstore" pstore "github.com/libp2p/go-libp2p-peerstore"
) )
...@@ -23,8 +25,8 @@ func TestMdnsDiscovery(t *testing.T) { ...@@ -23,8 +25,8 @@ func TestMdnsDiscovery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
a := netutil.GenHostSwarm(t, ctx) a := bhost.New(netutil.GenSwarmNetwork(t, ctx))
b := netutil.GenHostSwarm(t, ctx) b := bhost.New(netutil.GenSwarmNetwork(t, ctx))
sa, err := NewMdnsService(ctx, a, time.Second) sa, err := NewMdnsService(ctx, a, time.Second)
if err != nil { if err != nil {
......
package basichost_test package basichost
import ( import (
"bytes" "bytes"
...@@ -9,15 +9,15 @@ import ( ...@@ -9,15 +9,15 @@ import (
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
testutil "github.com/libp2p/go-libp2p-netutil"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-protocol"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
) )
func TestHostSimple(t *testing.T) { func TestHostSimple(t *testing.T) {
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := New(testutil.GenSwarmNetwork(t, ctx))
defer h1.Close() defer h1.Close()
defer h2.Close() defer h2.Close()
...@@ -64,8 +64,8 @@ func TestHostSimple(t *testing.T) { ...@@ -64,8 +64,8 @@ func TestHostSimple(t *testing.T) {
} }
func getHostPair(ctx context.Context, t *testing.T) (host.Host, host.Host) { func getHostPair(ctx context.Context, t *testing.T) (host.Host, host.Host) {
h1 := testutil.GenHostSwarm(t, ctx) h1 := New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := New(testutil.GenSwarmNetwork(t, ctx))
h2pi := h2.Peerstore().PeerInfo(h2.ID()) h2pi := h2.Peerstore().PeerInfo(h2.ID())
if err := h1.Connect(ctx, h2pi); err != nil { if err := h1.Connect(ctx, h2pi); err != nil {
...@@ -170,8 +170,8 @@ func TestHostProtoPreknowledge(t *testing.T) { ...@@ -170,8 +170,8 @@ func TestHostProtoPreknowledge(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
h1 := testutil.GenHostSwarm(t, ctx) h1 := New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := New(testutil.GenSwarmNetwork(t, ctx))
conn := make(chan protocol.ID, 16) conn := make(chan protocol.ID, 16)
handler := func(s inet.Stream) { handler := func(s inet.Stream) {
......
...@@ -8,12 +8,12 @@ import ( ...@@ -8,12 +8,12 @@ import (
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
p2putil "github.com/libp2p/go-libp2p/p2p/test/util"
"github.com/jbenet/goprocess" "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
ic "github.com/libp2p/go-libp2p-crypto" ic "github.com/libp2p/go-libp2p-crypto"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
p2putil "github.com/libp2p/go-libp2p-netutil"
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore" pstore "github.com/libp2p/go-libp2p-peerstore"
testutil "github.com/libp2p/go-testutil" testutil "github.com/libp2p/go-testutil"
......
...@@ -6,24 +6,27 @@ import ( ...@@ -6,24 +6,27 @@ import (
"time" "time"
ic "github.com/libp2p/go-libp2p-crypto" ic "github.com/libp2p/go-libp2p-crypto"
testutil "github.com/libp2p/go-libp2p-netutil"
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
blhost "github.com/libp2p/go-libp2p-blankhost"
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
func subtestIDService(t *testing.T, postDialWait time.Duration) { func subtestIDService(t *testing.T, postDialWait time.Duration) {
// the generated networks should have the id service wired in.
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := blhost.NewBlankHost(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := blhost.NewBlankHost(testutil.GenSwarmNetwork(t, ctx))
h1p := h1.ID() h1p := h1.ID()
h2p := h2.ID() h2p := h2.ID()
ids1 := identify.NewIDService(h1)
ids2 := identify.NewIDService(h2)
testKnowsAddrs(t, h1, h2p, []ma.Multiaddr{}) // nothing testKnowsAddrs(t, h1, h2p, []ma.Multiaddr{}) // nothing
testKnowsAddrs(t, h2, h1p, []ma.Multiaddr{}) // nothing testKnowsAddrs(t, h2, h1p, []ma.Multiaddr{}) // nothing
...@@ -32,11 +35,13 @@ func subtestIDService(t *testing.T, postDialWait time.Duration) { ...@@ -32,11 +35,13 @@ func subtestIDService(t *testing.T, postDialWait time.Duration) {
t.Fatal(err) t.Fatal(err)
} }
// we need to wait here if Dial returns before ID service is finished. h1t2c := h1.Network().ConnsToPeer(h2p)
if postDialWait > 0 { if len(h1t2c) == 0 {
<-time.After(postDialWait) t.Fatal("should have a conn here")
} }
ids1.IdentifyConn(h1t2c[0])
// the IDService should be opened automatically, by the network. // the IDService should be opened automatically, by the network.
// what we should see now is that both peers know about each others listen addresses. // what we should see now is that both peers know about each others listen addresses.
t.Log("test peer1 has peer2 addrs correctly") t.Log("test peer1 has peer2 addrs correctly")
...@@ -50,7 +55,7 @@ func subtestIDService(t *testing.T, postDialWait time.Duration) { ...@@ -50,7 +55,7 @@ func subtestIDService(t *testing.T, postDialWait time.Duration) {
if len(c) < 1 { if len(c) < 1 {
t.Fatal("should have connection by now at least.") t.Fatal("should have connection by now at least.")
} }
<-h2.IDService().IdentifyWait(c[0]) ids2.IdentifyConn(c[0])
addrs := h1.Peerstore().Addrs(h1p) addrs := h1.Peerstore().Addrs(h1p)
addrs = append(addrs, c[0].RemoteMultiaddr()) addrs = append(addrs, c[0].RemoteMultiaddr())
......
package ping package ping
import ( import (
"context"
"testing" "testing"
"time" "time"
netutil "github.com/libp2p/go-libp2p/p2p/test/util" netutil "github.com/libp2p/go-libp2p-netutil"
"context"
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore" pstore "github.com/libp2p/go-libp2p-peerstore"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
) )
func TestPing(t *testing.T) { func TestPing(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
h1 := netutil.GenHostSwarm(t, ctx) h1 := bhost.New(netutil.GenSwarmNetwork(t, ctx))
h2 := netutil.GenHostSwarm(t, ctx) h2 := bhost.New(netutil.GenSwarmNetwork(t, ctx))
err := h1.Connect(ctx, pstore.PeerInfo{ err := h1.Connect(ctx, pstore.PeerInfo{
ID: h2.ID(), ID: h2.ID(),
......
package relay_test package relay_test
import ( import (
"context"
"io" "io"
"testing" "testing"
"context" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
relay "github.com/libp2p/go-libp2p/p2p/protocol/relay"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
testutil "github.com/libp2p/go-libp2p-netutil"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-protocol"
relay "github.com/libp2p/go-libp2p/p2p/protocol/relay"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
msmux "github.com/whyrusleeping/go-multistream" msmux "github.com/whyrusleeping/go-multistream"
) )
...@@ -20,9 +22,9 @@ func TestRelaySimple(t *testing.T) { ...@@ -20,9 +22,9 @@ func TestRelaySimple(t *testing.T) {
ctx := context.Background() ctx := context.Background()
// these networks have the relay service wired in already. // these networks have the relay service wired in already.
n1 := testutil.GenHostSwarm(t, ctx) n1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n2 := testutil.GenHostSwarm(t, ctx) n2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n3 := testutil.GenHostSwarm(t, ctx) n3 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n1p := n1.ID() n1p := n1.ID()
n2p := n2.ID() n2p := n2.ID()
...@@ -103,11 +105,11 @@ func TestRelayAcrossFour(t *testing.T) { ...@@ -103,11 +105,11 @@ func TestRelayAcrossFour(t *testing.T) {
ctx := context.Background() ctx := context.Background()
// these networks have the relay service wired in already. // these networks have the relay service wired in already.
n1 := testutil.GenHostSwarm(t, ctx) n1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n2 := testutil.GenHostSwarm(t, ctx) n2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n3 := testutil.GenHostSwarm(t, ctx) n3 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n4 := testutil.GenHostSwarm(t, ctx) n4 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n5 := testutil.GenHostSwarm(t, ctx) n5 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n1p := n1.ID() n1p := n1.ID()
n2p := n2.ID() n2p := n2.ID()
...@@ -215,9 +217,9 @@ func TestRelayStress(t *testing.T) { ...@@ -215,9 +217,9 @@ func TestRelayStress(t *testing.T) {
ctx := context.Background() ctx := context.Background()
// these networks have the relay service wired in already. // these networks have the relay service wired in already.
n1 := testutil.GenHostSwarm(t, ctx) n1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n2 := testutil.GenHostSwarm(t, ctx) n2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n3 := testutil.GenHostSwarm(t, ctx) n3 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
n1p := n1.ID() n1p := n1.ID()
n2p := n2.ID() n2p := n2.ID()
......
package backpressure_tests package backpressure_tests
import ( import (
"context"
"io" "io"
"math/rand" "math/rand"
"testing" "testing"
"time" "time"
"context" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
testutil "github.com/libp2p/go-libp2p-netutil"
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-protocol"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
) )
var log = logging.Logger("backpressure") var log = logging.Logger("backpressure")
...@@ -135,8 +137,8 @@ a problem. ...@@ -135,8 +137,8 @@ a problem.
// ok that's enough setup. let's do it! // ok that's enough setup. let's do it!
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
// setup receiver handler // setup receiver handler
h1.SetStreamHandler(protocol.TestingID, receiver) h1.SetStreamHandler(protocol.TestingID, receiver)
...@@ -272,8 +274,8 @@ func TestStBackpressureStreamWrite(t *testing.T) { ...@@ -272,8 +274,8 @@ func TestStBackpressureStreamWrite(t *testing.T) {
// setup the networks // setup the networks
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
// setup sender handler on 1 // setup sender handler on 1
h1.SetStreamHandler(protocol.TestingID, sender) h1.SetStreamHandler(protocol.TestingID, sender)
......
...@@ -8,13 +8,15 @@ import ( ...@@ -8,13 +8,15 @@ import (
"testing" "testing"
"time" "time"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
testutil "github.com/libp2p/go-libp2p-netutil"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-protocol"
swarm "github.com/libp2p/go-libp2p-swarm" swarm "github.com/libp2p/go-libp2p-swarm"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
ps "github.com/libp2p/go-peerstream" ps "github.com/libp2p/go-peerstream"
) )
...@@ -103,8 +105,8 @@ func newSender() (chan sendChans, func(s inet.Stream)) { ...@@ -103,8 +105,8 @@ func newSender() (chan sendChans, func(s inet.Stream)) {
// TestReconnect tests whether hosts are able to disconnect and reconnect. // TestReconnect tests whether hosts are able to disconnect and reconnect.
func TestReconnect2(t *testing.T) { func TestReconnect2(t *testing.T) {
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
hosts := []host.Host{h1, h2} hosts := []host.Host{h1, h2}
h1.SetStreamHandler(protocol.TestingID, EchoStreamHandler) h1.SetStreamHandler(protocol.TestingID, EchoStreamHandler)
...@@ -123,11 +125,11 @@ func TestReconnect2(t *testing.T) { ...@@ -123,11 +125,11 @@ func TestReconnect2(t *testing.T) {
// TestReconnect tests whether hosts are able to disconnect and reconnect. // TestReconnect tests whether hosts are able to disconnect and reconnect.
func TestReconnect5(t *testing.T) { func TestReconnect5(t *testing.T) {
ctx := context.Background() ctx := context.Background()
h1 := testutil.GenHostSwarm(t, ctx) h1 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h2 := testutil.GenHostSwarm(t, ctx) h2 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h3 := testutil.GenHostSwarm(t, ctx) h3 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h4 := testutil.GenHostSwarm(t, ctx) h4 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
h5 := testutil.GenHostSwarm(t, ctx) h5 := bhost.New(testutil.GenSwarmNetwork(t, ctx))
hosts := []host.Host{h1, h2, h3, h4, h5} hosts := []host.Host{h1, h2, h3, h4, h5}
h1.SetStreamHandler(protocol.TestingID, EchoStreamHandler) h1.SetStreamHandler(protocol.TestingID, EchoStreamHandler)
......
package testutil
import (
"bytes"
"io"
"testing"
u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log"
ic "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
testutil "github.com/libp2p/go-testutil"
ma "github.com/multiformats/go-multiaddr"
)
var log = logging.Logger("boguskey")
// TestBogusPrivateKey is a key used for testing (to avoid expensive keygen)
type TestBogusPrivateKey []byte
// TestBogusPublicKey is a key used for testing (to avoid expensive keygen)
type TestBogusPublicKey []byte
func (pk TestBogusPublicKey) Verify(data, sig []byte) (bool, error) {
log.Errorf("TestBogusPublicKey.Verify -- this better be a test!")
return bytes.Equal(data, reverse(sig)), nil
}
func (pk TestBogusPublicKey) Bytes() ([]byte, error) {
return []byte(pk), nil
}
func (pk TestBogusPublicKey) Encrypt(b []byte) ([]byte, error) {
log.Errorf("TestBogusPublicKey.Encrypt -- this better be a test!")
return reverse(b), nil
}
// Equals checks whether this key is equal to another
func (pk TestBogusPublicKey) Equals(k ic.Key) bool {
return ic.KeyEqual(pk, k)
}
func (pk TestBogusPublicKey) Hash() ([]byte, error) {
return ic.KeyHash(pk)
}
func (sk TestBogusPrivateKey) GenSecret() []byte {
return []byte(sk)
}
func (sk TestBogusPrivateKey) Sign(message []byte) ([]byte, error) {
log.Errorf("TestBogusPrivateKey.Sign -- this better be a test!")
return reverse(message), nil
}
func (sk TestBogusPrivateKey) GetPublic() ic.PubKey {
return TestBogusPublicKey(sk)
}
func (sk TestBogusPrivateKey) Decrypt(b []byte) ([]byte, error) {
log.Errorf("TestBogusPrivateKey.Decrypt -- this better be a test!")
return reverse(b), nil
}
func (sk TestBogusPrivateKey) Bytes() ([]byte, error) {
return []byte(sk), nil
}
// Equals checks whether this key is equal to another
func (sk TestBogusPrivateKey) Equals(k ic.Key) bool {
return ic.KeyEqual(sk, k)
}
func (sk TestBogusPrivateKey) Hash() ([]byte, error) {
return ic.KeyHash(sk)
}
func RandTestBogusPrivateKey() (TestBogusPrivateKey, error) {
r := u.NewTimeSeededRand()
k := make([]byte, 5)
if _, err := io.ReadFull(r, k); err != nil {
return nil, err
}
return TestBogusPrivateKey(k), nil
}
func RandTestBogusPublicKey() (TestBogusPublicKey, error) {
k, err := RandTestBogusPrivateKey()
return TestBogusPublicKey(k), err
}
func RandTestBogusPrivateKeyOrFatal(t *testing.T) TestBogusPrivateKey {
k, err := RandTestBogusPrivateKey()
if err != nil {
t.Fatal(err)
}
return k
}
func RandTestBogusPublicKeyOrFatal(t *testing.T) TestBogusPublicKey {
k, err := RandTestBogusPublicKey()
if err != nil {
t.Fatal(err)
}
return k
}
func RandTestBogusIdentity() (testutil.Identity, error) {
k, err := RandTestBogusPrivateKey()
if err != nil {
return nil, err
}
id, err := peer.IDFromPrivateKey(k)
if err != nil {
return nil, err
}
return &identity{
k: k,
id: id,
a: testutil.RandLocalTCPAddress(),
}, nil
}
func RandTestBogusIdentityOrFatal(t *testing.T) testutil.Identity {
k, err := RandTestBogusIdentity()
if err != nil {
t.Fatal(err)
}
return k
}
// identity is a temporary shim to delay binding of PeerNetParams.
type identity struct {
k TestBogusPrivateKey
id peer.ID
a ma.Multiaddr
}
func (p *identity) ID() peer.ID {
return p.id
}
func (p *identity) Address() ma.Multiaddr {
return p.a
}
func (p *identity) PrivateKey() ic.PrivKey {
return p.k
}
func (p *identity) PublicKey() ic.PubKey {
return p.k.GetPublic()
}
func reverse(a []byte) []byte {
b := make([]byte, len(a))
for i := 0; i < len(a); i++ {
b[i] = a[len(a)-1-i]
}
return b
}
package testutil
import (
"context"
"testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
metrics "github.com/libp2p/go-libp2p-metrics"
inet "github.com/libp2p/go-libp2p-net"
pstore "github.com/libp2p/go-libp2p-peerstore"
swarm "github.com/libp2p/go-libp2p-swarm"
tu "github.com/libp2p/go-testutil"
ma "github.com/multiformats/go-multiaddr"
)
func GenSwarmNetwork(t *testing.T, ctx context.Context) *swarm.Network {
p := tu.RandPeerNetParamsOrFatal(t)
ps := pstore.NewPeerstore()
ps.AddPubKey(p.ID, p.PubKey)
ps.AddPrivKey(p.ID, p.PrivKey)
n, err := swarm.NewNetwork(ctx, []ma.Multiaddr{p.Addr}, p.ID, ps, metrics.NewBandwidthCounter())
if err != nil {
t.Fatal(err)
}
ps.AddAddrs(p.ID, n.ListenAddresses(), pstore.PermanentAddrTTL)
return n
}
func DivulgeAddresses(a, b inet.Network) {
id := a.LocalPeer()
addrs := a.Peerstore().Addrs(id)
b.Peerstore().AddAddrs(id, addrs, pstore.PermanentAddrTTL)
}
func GenHostSwarm(t *testing.T, ctx context.Context) *bhost.BasicHost {
n := GenSwarmNetwork(t, ctx)
return bhost.New(n)
}
var RandPeerID = tu.RandPeerID
...@@ -226,6 +226,18 @@ ...@@ -226,6 +226,18 @@
"hash": "QmPpncQ3L4bC3rnwLBrgEomygs5RbnFejb68GgsecxbMiL", "hash": "QmPpncQ3L4bC3rnwLBrgEomygs5RbnFejb68GgsecxbMiL",
"name": "go-libp2p-nat", "name": "go-libp2p-nat",
"version": "0.0.0" "version": "0.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmcDTquYLTYirqj71RRWKUWEEw3nJt11Awzun5ep8kfY7W",
"name": "go-libp2p-netutil",
"version": "0.1.0"
},
{
"author": "whyrusleeping",
"hash": "QmYjDhB1VkuP5ATkqjdnPHfA2huyfcydNMXoGdtEvTNcYL",
"name": "go-libp2p-blankhost",
"version": "0.1.0"
} }
], ],
"gxVersion": "0.4.0", "gxVersion": "0.4.0",
...@@ -235,3 +247,4 @@ ...@@ -235,3 +247,4 @@
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "4.1.0" "version": "4.1.0"
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment