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

remove flaky TestTcpSimultaneousConnect #1425

Merged
merged 1 commit into from
Apr 22, 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
49 changes: 0 additions & 49 deletions libp2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"regexp"
"strings"
"sync"
"testing"

"github.com/libp2p/go-libp2p/p2p/transport/tcp"
Expand All @@ -16,9 +15,6 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"

noise "github.com/libp2p/go-libp2p-noise"

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

Expand Down Expand Up @@ -168,48 +164,3 @@ func TestChainOptions(t *testing.T) {
}
}
}

func TestTcpSimultaneousConnect(t *testing.T) {
// Host1
h1, err := New(Transport(tcp.NewTCPTransport), Security(noise.ID, noise.New), ListenAddrs(ma.StringCast("/ip4/0.0.0.0/tcp/0")))
require.NoError(t, err)
defer h1.Close()

// Host2
h2, err := New(Transport(tcp.NewTCPTransport), Security(noise.ID, noise.New), ListenAddrs(ma.StringCast("/ip4/0.0.0.0/tcp/0")))
require.NoError(t, err)
defer h2.Close()

h1Info := peer.AddrInfo{
ID: h1.ID(),
Addrs: h1.Addrs(),
}

h2Info := peer.AddrInfo{
ID: h2.ID(),
Addrs: h2.Addrs(),
}

wg := new(sync.WaitGroup)

wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 20; i++ {
require.NoError(t, h1.Connect(context.Background(), h2Info))
require.NoError(t, h1.Network().ClosePeer(h2.ID()))
}
}()

// use another peer to constantly connect/disconnect with first peer.
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 20; i++ {
require.NoError(t, h2.Connect(context.Background(), h1Info))
require.NoError(t, h2.Network().ClosePeer(h1.ID()))
}
}()

wg.Wait()
}