@@ -8,15 +8,17 @@ import (
8
8
"testing"
9
9
"time"
10
10
11
- "github.com/stretchr/testify/require "
11
+ bhost "github.com/libp2p/go-libp2p/p2p/host/basic "
12
12
13
- u "github.com/ipfs/go-ipfs-util"
14
- logging "github.com/ipfs/go-log/v2"
15
13
"github.com/libp2p/go-libp2p-core/host"
16
14
"github.com/libp2p/go-libp2p-core/network"
17
15
"github.com/libp2p/go-libp2p-core/protocol"
16
+
18
17
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"
20
22
)
21
23
22
24
var log = logging .Logger ("reconnect" )
@@ -102,9 +104,11 @@ func newSender() (chan sendChans, func(s network.Stream)) {
102
104
103
105
// TestReconnect tests whether hosts are able to disconnect and reconnect.
104
106
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 )
106
110
require .NoError (t , err )
107
- h2 , err := bhost .NewHost (swarmt .GenSwarm (t ), nil )
111
+ h2 , err := bhost .NewHost (swarmt .GenSwarm (t , swarmt . OptDisableTCP ), nil )
108
112
require .NoError (t , err )
109
113
hosts := []host.Host {h1 , h2 }
110
114
@@ -117,7 +121,7 @@ func TestReconnect2(t *testing.T) {
117
121
}
118
122
for i := 0 ; i < rounds ; i ++ {
119
123
log .Debugf ("TestReconnect: %d/%d\n " , i , rounds )
120
- SubtestConnSendDisc (t , hosts )
124
+ subtestConnSendDisc (t , hosts )
121
125
}
122
126
}
123
127
@@ -126,7 +130,9 @@ func TestReconnect5(t *testing.T) {
126
130
const num = 5
127
131
hosts := make ([]host.Host , 0 , num )
128
132
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 )
130
136
require .NoError (t , err )
131
137
h .SetStreamHandler (protocol .TestingID , EchoStreamHandler )
132
138
hosts = append (hosts , h )
@@ -138,12 +144,11 @@ func TestReconnect5(t *testing.T) {
138
144
}
139
145
for i := 0 ; i < rounds ; i ++ {
140
146
log .Debugf ("TestReconnect: %d/%d\n " , i , rounds )
141
- SubtestConnSendDisc (t , hosts )
147
+ subtestConnSendDisc (t , hosts )
142
148
}
143
149
}
144
150
145
- func SubtestConnSendDisc (t * testing.T , hosts []host.Host ) {
146
-
151
+ func subtestConnSendDisc (t * testing.T , hosts []host.Host ) {
147
152
ctx := context .Background ()
148
153
numStreams := 3 * len (hosts )
149
154
numMsgs := 10
0 commit comments