Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ping: fix flaky test #1617

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a change we can do that does this at a higher level? I think we see this flakiness in other tests too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, this is not the first time I'm submitting a patch like this.

At which level would you suggest to do it?

})
require.NoError(t, err)

Expand Down