Skip to content

Commit

Permalink
ping: fix flaky test (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Jun 30, 2022
1 parent 17464c3 commit 95e9ff7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions p2p/protocol/ping/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
"github.com/libp2p/go-libp2p/p2p/protocol/ping"

"github.com/libp2p/go-libp2p-core/peer"

ma "github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
)

func TestPing(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
h1, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
require.NoError(t, err)
defer h1.Close()
h2, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
require.NoError(t, err)
defer h2.Close()

err = h1.Connect(ctx, peer.AddrInfo{
ID: h2.ID(),
Addrs: h2.Addrs(),
Addrs: []ma.Multiaddr{h2.Addrs()[0]},
})
require.NoError(t, err)

Expand Down

0 comments on commit 95e9ff7

Please sign in to comment.