diff --git a/tests/stress/helpers.go b/tests/stress/helpers.go index dc8e51eaa7..d1cf35a00e 100644 --- a/tests/stress/helpers.go +++ b/tests/stress/helpers.go @@ -20,8 +20,7 @@ import ( ) var ( - testTimeout = time.Minute * 3 - logger = log.NewFromGlobal(log.AddContext("pkg", "tests/stress")) + logger = log.NewFromGlobal(log.AddContext("pkg", "tests/stress")) ) // compareChainHeads calls getChainHead for each node in the array diff --git a/tests/stress/stress_test.go b/tests/stress/stress_test.go index e2ff3fc457..c8cfb976c2 100644 --- a/tests/stress/stress_test.go +++ b/tests/stress/stress_test.go @@ -326,23 +326,23 @@ func TestSync_Bench(t *testing.T) { start := time.Now() var end time.Time + const retryWait = time.Second + const syncWaitTimeout = 3 * time.Minute + syncWaitCtx, syncWaitCancel := context.WithTimeout(ctx, syncWaitTimeout) for { - if time.Since(start) >= testTimeout { - t.Fatal("did not sync") - } - - getChainHeadCtx, getChainHeadCancel := context.WithTimeout(ctx, time.Second) + getChainHeadCtx, getChainHeadCancel := context.WithTimeout(syncWaitCtx, time.Second) head, err := rpc.GetChainHead(getChainHeadCtx, bob.GetRPCPort()) getChainHeadCancel() - if err != nil { - continue - } - - if head.Number >= last { + if err == nil && head.Number >= last { end = time.Now() + syncWaitCancel() break } + + retryWaitCtx, retryWaitCancel := context.WithTimeout(syncWaitCtx, retryWait) + <-retryWaitCtx.Done() + retryWaitCancel() } maxTime := time.Second * 85