Skip to content

Commit c9dbd16

Browse files
committed
fix: failing kademlia test
1 parent 4a71069 commit c9dbd16

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkg/topology/kademlia/kademlia_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,12 @@ func TestAddressBookPrune(t *testing.T) {
837837
// add non connectable peer, check connection and failed connection counters
838838
kad.AddPeers(nonConnPeer.Overlay)
839839

840-
kad.Trigger()
841-
kad.Trigger()
840+
for range 5 {
841+
kad.Trigger()
842+
}
842843

843844
waitCounter(t, &conns, 0)
844-
waitCounter(t, &failedConns, 3)
845+
waitCounter(t, &failedConns, 6)
845846

846847
_, err = ab.Get(nonConnPeer.Overlay)
847848
if !errors.Is(err, addressbook.ErrNotFound) {
@@ -923,6 +924,13 @@ func TestAddressBookQuickPrune_FLAKY(t *testing.T) {
923924
waitCounter(t, &conns, 0)
924925
waitCounter(t, &failedConns, 1)
925926

927+
// we need to trigger connection attempts maxConnAttempts times
928+
for range 3 {
929+
time.Sleep(10 * time.Millisecond)
930+
kad.Trigger()
931+
waitCounter(t, &failedConns, 1)
932+
}
933+
926934
_, err = ab.Get(nonConnPeer.Overlay)
927935
if !errors.Is(err, addressbook.ErrNotFound) {
928936
t.Fatal(err)

0 commit comments

Comments
 (0)