From b3f1f4c673271258f18c61d8b6e5cda9849da27a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 17 Dec 2015 23:28:27 +0100 Subject: [PATCH] p2p/discover: attempt to deflake TestUDP_responseTimeouts The test expected the timeout to fire after a matcher for the response was added, but the timeout is random and fired sooner sometimes. --- p2p/discover/udp_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go index 55d6d564a3..8ed12b8eca 100644 --- a/p2p/discover/udp_test.go +++ b/p2p/discover/udp_test.go @@ -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)) }