Skip to content

Commit

Permalink
p2p/discover: attempt to deflake TestUDP_responseTimeouts
Browse files Browse the repository at this point in the history
The test expected the timeout to fire after a matcher for the response
was added, but the timeout is random and fired sooner sometimes.
  • Loading branch information
fjl committed Dec 17, 2015
1 parent 6c41e67 commit b3f1f4c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion p2p/discover/udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,17 @@ func TestUDP_responseTimeouts(t *testing.T) {
binary.BigEndian.PutUint64(p.from[:], uint64(i))
if p.ptype <= 128 {
p.errc = timeoutErr
test.udp.addpending <- p
nTimeouts++
} else {
p.errc = nilErr
test.udp.addpending <- p
time.AfterFunc(randomDuration(60*time.Millisecond), func() {
if !test.udp.handleReply(p.from, p.ptype, nil) {
t.Logf("not matched: %v", p)
}
})
}
test.udp.addpending <- p
time.Sleep(randomDuration(30 * time.Millisecond))
}

Expand Down

0 comments on commit b3f1f4c

Please sign in to comment.