mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-09 18:28:08 +08:00
attempt at fixing TestRoutingProvide
This commit is contained in:
parent
4076744cee
commit
1aafcd929e
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user