From 073f01002da3a86a8ea53a0d09f04f9760a1953f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 26 Jun 2022 12:31:51 +0200 Subject: [PATCH] ping: fix flaky test --- p2p/protocol/ping/ping_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/p2p/protocol/ping/ping_test.go b/p2p/protocol/ping/ping_test.go index 75021b1406..51e7f18f0e 100644 --- a/p2p/protocol/ping/ping_test.go +++ b/p2p/protocol/ping/ping_test.go @@ -5,13 +5,14 @@ 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) { @@ -19,12 +20,14 @@ func TestPing(t *testing.T) { 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)