From b4e13404a30f2cdc88a76c735a3cb128dcdee4e7 Mon Sep 17 00:00:00 2001 From: Marius Guggenmos Date: Tue, 30 Jul 2024 09:48:23 +0200 Subject: [PATCH] p2p: fix flaky test TestServerPortMapping The test specifies `ListenAddr: ":0"`, which means a random ephemeral port will be chosen for the TCP listener by the OS. Additionally, since no `DiscAddr` was specified, the same port that is chosen automatically by the OS will also be used for the UDP listener in the discovery UDP setup. This sometimes leads to test failures if the TCP listener picks a free TCP port that is already taken for UDP. By specifying `DiscAddr: ":0"`, the UDP port will be chosen independently from the TCP port, fixing the random failure. See issue #29830. --- p2p/server_nat_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/p2p/server_nat_test.go b/p2p/server_nat_test.go index cbb1f37e0a6..7e193872104 100644 --- a/p2p/server_nat_test.go +++ b/p2p/server_nat_test.go @@ -36,6 +36,7 @@ func TestServerPortMapping(t *testing.T) { PrivateKey: newkey(), NoDial: true, ListenAddr: ":0", + DiscAddr: ":0", NAT: mockNAT, Logger: testlog.Logger(t, log.LvlTrace), clock: clock,