p2p/discover: fix flaky TestUDPv5_findnodeHandling (#34109)

Fixes #34108

The UDPv5 test harness (`newUDPV5Test`) uses the default `PingInterval`
of 3 seconds. When tests like `TestUDPv5_findnodeHandling` insert nodes
into the routing table via `fillTable`, the table's revalidation loop
may schedule PING packets for those nodes. Under the race detector or on
slow CI runners, the test runs long enough for revalidation to fire,
causing background pings to be written to the test pipe. The `close()`
method then finds these as unmatched packets and fails.

The fix sets `PingInterval` to a very large value in the test harness so
revalidation never fires during tests.

Verified locally: 100 iterations with `-race -count=100` pass reliably,
where previously the test would fail within ~50 iterations.
This commit is contained in:
Charles Dusek 2026-04-14 02:43:44 -05:00 committed by GitHub
parent 01e33d14be
commit e1fe4a1a98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -937,6 +937,7 @@ func newUDPV5Test(t *testing.T) *udpV5Test {
PrivateKey: test.localkey,
Log: testlog.Logger(t, log.LvlTrace),
ValidSchemes: enode.ValidSchemesForTesting,
PingInterval: 1000 * time.Hour,
})
test.udp.codec = &testCodec{test: test, id: ln.ID()}
test.table = test.udp.tab