Skip to content

Commit 9bb973c

Browse files
Merge pull request #1268 from libp2p/reconnect-on-quic
run reconnect test using QUIC
2 parents e014b96 + c17d397 commit 9bb973c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

p2p/test/reconnects/reconnect_test.go

+16-11
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/stretchr/testify/require"
11+
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
1212

13-
u "github.com/ipfs/go-ipfs-util"
14-
logging "github.com/ipfs/go-log/v2"
1513
"github.com/libp2p/go-libp2p-core/host"
1614
"github.com/libp2p/go-libp2p-core/network"
1715
"github.com/libp2p/go-libp2p-core/protocol"
16+
1817
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
19-
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
18+
19+
u "github.com/ipfs/go-ipfs-util"
20+
logging "github.com/ipfs/go-log/v2"
21+
"github.com/stretchr/testify/require"
2022
)
2123

2224
var log = logging.Logger("reconnect")
@@ -102,9 +104,11 @@ func newSender() (chan sendChans, func(s network.Stream)) {
102104

103105
// TestReconnect tests whether hosts are able to disconnect and reconnect.
104106
func TestReconnect2(t *testing.T) {
105-
h1, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
107+
// TCP RST handling is flaky in OSX, see https://github.com/golang/go/issues/50254.
108+
// We can avoid this by using QUIC in this test.
109+
h1, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
106110
require.NoError(t, err)
107-
h2, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
111+
h2, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
108112
require.NoError(t, err)
109113
hosts := []host.Host{h1, h2}
110114

@@ -117,7 +121,7 @@ func TestReconnect2(t *testing.T) {
117121
}
118122
for i := 0; i < rounds; i++ {
119123
log.Debugf("TestReconnect: %d/%d\n", i, rounds)
120-
SubtestConnSendDisc(t, hosts)
124+
subtestConnSendDisc(t, hosts)
121125
}
122126
}
123127

@@ -126,7 +130,9 @@ func TestReconnect5(t *testing.T) {
126130
const num = 5
127131
hosts := make([]host.Host, 0, num)
128132
for i := 0; i < num; i++ {
129-
h, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
133+
// TCP RST handling is flaky in OSX, see https://github.com/golang/go/issues/50254.
134+
// We can avoid this by using QUIC in this test.
135+
h, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
130136
require.NoError(t, err)
131137
h.SetStreamHandler(protocol.TestingID, EchoStreamHandler)
132138
hosts = append(hosts, h)
@@ -138,12 +144,11 @@ func TestReconnect5(t *testing.T) {
138144
}
139145
for i := 0; i < rounds; i++ {
140146
log.Debugf("TestReconnect: %d/%d\n", i, rounds)
141-
SubtestConnSendDisc(t, hosts)
147+
subtestConnSendDisc(t, hosts)
142148
}
143149
}
144150

145-
func SubtestConnSendDisc(t *testing.T, hosts []host.Host) {
146-
151+
func subtestConnSendDisc(t *testing.T, hosts []host.Host) {
147152
ctx := context.Background()
148153
numStreams := 3 * len(hosts)
149154
numMsgs := 10

0 commit comments

Comments
 (0)