prysm-pulse/shared/deprecated-p2p/monitoring_test.go
Preston Van Loon 82efca9b6f
Move p2p to deprecated-p2p (#3191)
* move to deprecated-p2p

* fix lint

* lint?

* fix lint

* lint

* lint

* lint

* lint
2019-08-13 14:52:04 -04:00

32 lines
731 B
Go

package p2p
import (
"context"
"testing"
bhost "github.com/libp2p/go-libp2p-blankhost"
pstore "github.com/libp2p/go-libp2p-peerstore"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
)
func TestEnsurePeerConnections_reconnectsToPeer(t *testing.T) {
ctx := context.Background()
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
vipPeer := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
vipMAddrs, err := pstore.InfoToP2pAddrs(&pstore.PeerInfo{ID: vipPeer.ID(), Addrs: vipPeer.Addrs()})
if err != nil {
t.Fatal(err)
}
if len(h.Peerstore().Peers()) != 1 {
t.Fatal("expected 1 peer")
}
ensurePeerConnections(ctx, h, vipMAddrs[0].String())
if len(h.Peerstore().Peers()) != 2 {
t.Fatal("expected 2 peers")
}
}