Skip to content

Commit 7e6e3a2

Browse files
authored
Merge pull request #6287 from oasisprotocol/peternose/trivial/fix-churp-test
go/oasis-test-runner: Fix flaky CHURP test
2 parents 932aaaa + 7ca6635 commit 7e6e3a2

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

.changelog/6287.trivial.md

Whitespace-only changes.

go/worker/keymanager/churp.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"sync"
1111
"time"
1212

13-
"github.com/cenkalti/backoff/v4"
1413
"github.com/libp2p/go-libp2p/core"
1514
"golang.org/x/exp/maps"
1615

@@ -1051,11 +1050,9 @@ func (w *nodeWatcher) HasApplied(peerID core.PeerID) bool {
10511050
// retry attempts to execute the given function until it succeeds,
10521051
// reaches the maximum number of attempts, or the context expires.
10531052
func retry(ctx context.Context, fn func(int) error) error {
1054-
bo := cmnBackoff.NewExponentialBackOff()
1055-
bo.InitialInterval = retryInitialInterval
1056-
bo.Reset()
1057-
1058-
ticker := backoff.NewTicker(bo)
1053+
backoff := cmnBackoff.NewExponentialBackOff()
1054+
backoff.InitialInterval = retryInitialInterval
1055+
backoff.Reset()
10591056

10601057
var err error
10611058
for attempt := 1; attempt <= maxAttempts; attempt++ {
@@ -1064,9 +1061,9 @@ func retry(ctx context.Context, fn func(int) error) error {
10641061
}
10651062

10661063
select {
1067-
case <-ticker.C:
10681064
case <-ctx.Done():
10691065
return fmt.Errorf("%w: %w", ctx.Err(), context.Cause(ctx))
1066+
case <-time.After(backoff.NextBackOff()):
10701067
}
10711068
}
10721069

0 commit comments

Comments
 (0)