Skip to content

fix: flaky TestInvalidServer #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,14 +1536,15 @@ func TestInvalidServer(t *testing.T) {
time.Sleep(time.Millisecond * 5) // just in case...

// find the provider for k from m0
maxRetries := 3
maxRetries := 5
var provs []peer.AddrInfo
var err error
for i := 0; i < maxRetries && len(provs) == 0; i++ {
provs, err = m0.FindProviders(ctx, k)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Millisecond * 5)
}
if len(provs) == 0 {
t.Fatal("Expected to get a provider back")
Expand All @@ -1569,13 +1570,20 @@ func TestInvalidServer(t *testing.T) {
// s1 should be added to s0's routing table. Then, because s0's routing table
// contains more than bucketSize (2) entries, lookupCheck is enabled and m1
// shouldn't be added, because it fails the lookupCheck (hang on all requests).
if s0.routingTable.Find(s1.self) == "" {
time.Sleep(time.Millisecond * 5) // just in case...
if s0.routingTable.Find(s1.self) == "" {
t.Fatal("Well behaving DHT server should have been added to the server routing table")
s1Found := false
for i := 0; i < maxRetries; i++ {
if s0.routingTable.Find(s1.self) != "" {
s1Found = true
break
}
time.Sleep(time.Millisecond * 5)
}
if !s1Found {
t.Fatal("Well behaving DHT server should have been added to the server routing table")
}
if s0.routingTable.Find(m1.self) != "" {
t.Log("s0:", s0.self, ", s1:", s1.self, ", m0:", m0.self, ", m1:", m1.self)
t.Log("Routing Table peers", m0.routingTable.ListPeers())
t.Fatal("Misbehaving DHT servers should not be added to routing table if well populated")
}
}
Expand Down