p2p/net/swarm: fix TestDialBackoff
- attempts set to 1 now. - timeouts must account for that.
Juan Batiz-Benet committed
Jan 28, 2015 at 14:15 UTC
81bb548d234435e815268c923318e46478bacd03
1 file changed
+10
-10
p2p/net/swarm/dial_test.go
+10
-10
@@ -164,8 +164,8 @@ func TestDialBackoff(t *testing.T) {
164
defer s1.Close()
165
defer s2.Close()
166
167
- s1.dialT = time.Millisecond * 500 // lower timeout for tests.
168
- s2.dialT = time.Millisecond * 500 // lower timeout for tests.
167
+ s1.dialT = time.Second // lower timeout for tests.
168
+ s2.dialT = time.Second // lower timeout for tests.
169
170
s2addrs, err := s2.InterfaceListenAddresses()
171
if err != nil {
@@ -229,8 +229,8 @@ func TestDialBackoff(t *testing.T) {
229
230
// when all dials should be done by:
231
dialTimeout1x := time.After(s1.dialT)
232
- dialTimeout1Ax := time.After(s1.dialT * dialAttempts)
233
- dialTimeout10Ax := time.After(s1.dialT * dialAttempts * 10)
232
+ // dialTimeout1Ax := time.After(s1.dialT * 2) // dialAttempts)
233
+ dialTimeout10Ax := time.After(s1.dialT * 2 * 10) // dialAttempts * 10)
234
235
// 2) all dials should hang
236
select {
@@ -265,7 +265,7 @@ func TestDialBackoff(t *testing.T) {
265
}
266
267
// 4) s1->s3 should not (and should place s3 on backoff)
268
- // N-1 should finish before dialTimeout1Ax
268
+ // N-1 should finish before dialTimeout1x * 2
269
for i := 0; i < N; i++ {
270
select {
271
case <-s2done:
@@ -274,11 +274,11 @@ func TestDialBackoff(t *testing.T) {
274
if r {
275
t.Error("s3 should not succeed")
276
}
277
- case <-dialTimeout1Ax:
277
+ case <-(dialTimeout1x):
278
if i < (N - 1) {
279
t.Fatal("s3 took too long")
280
}
281
- t.Log("dialTimeout1Ax hit for last peer")
281
+ t.Log("dialTimeout1x * 1.3 hit for last peer")
282
case <-dialTimeout10Ax:
283
t.Fatal("s3 took too long")
284
}
@@ -313,8 +313,8 @@ func TestDialBackoff(t *testing.T) {
313
314
// when all dials should be done by:
315
dialTimeout1x := time.After(s1.dialT)
316
- dialTimeout1Ax := time.After(s1.dialT * dialAttempts)
317
- dialTimeout10Ax := time.After(s1.dialT * dialAttempts * 10)
316
+ // dialTimeout1Ax := time.After(s1.dialT * 2) // dialAttempts)
317
+ dialTimeout10Ax := time.After(s1.dialT * 2 * 10) // dialAttempts * 10)
318
319
// 7) s3 dials should all return immediately (except 1)
320
for i := 0; i < N-1; i++ {
@@ -338,7 +338,7 @@ func TestDialBackoff(t *testing.T) {
338
t.Error("s2 should succeed")
339
}
340
// case <-s3done:
341
- case <-dialTimeout1Ax:
341
+ case <-(dialTimeout1x):
342
t.Fatal("s3 took too long")
343
}
344
}