attempt at fixing TestRoutingProvide

This commit is contained in:
guillaumemichel 2025-10-23 21:44:54 +02:00
parent 4076744cee
commit 1aafcd929e
No known key found for this signature in database
GPG Key ID: 612745DB2E6D0E15

View File

@ -240,14 +240,26 @@ func (tp *TestSuite) TestRoutingProvide(t *testing.T) {
t.Fatal(err)
}
out, err = apis[2].Routing().FindProviders(ctx, p, options.Routing.NumProviders(1))
if err != nil {
t.Fatal(err)
maxAttempts := 5
success := false
for range maxAttempts {
// We may need to try again as Provide() doesn't block until the CID is
// actually provided.
out, err = apis[2].Routing().FindProviders(ctx, p, options.Routing.NumProviders(1))
if err != nil {
t.Fatal(err)
}
provider := <-out
if provider.ID.String() == self0.ID().String() {
success = true
break
} else if len(provider.ID.String()) > 0 {
t.Errorf("got wrong provider: %s != %s", provider.ID.String(), self0.ID().String())
}
time.Sleep(time.Second)
}
provider := <-out
if provider.ID.String() != self0.ID().String() {
t.Errorf("got wrong provider: %s != %s", provider.ID.String(), self0.ID().String())
if !success {
t.Errorf("missing provider after %d attempts", maxAttempts)
}
}