p2p/discover: wait for bootstrap to be done (#32881)

This ensures the node is ready to accept other nodes into the
table before it is used in a test.

Closes #32863
This commit is contained in:
Delweng 2025-10-14 01:58:50 +08:00 committed by Alvarez
parent f86ec0c245
commit 592c54069d

View file

@ -575,6 +575,13 @@ func startLocalhostV4(t *testing.T, cfg Config) *UDPv4 {
if err != nil {
t.Fatal(err)
}
// Wait for bootstrap to complete.
select {
case <-udp.tab.initDone:
case <-time.After(5 * time.Second):
t.Fatalf("timed out waiting for table initialization")
}
return udp
}