@@ -422,6 +422,8 @@ func waitForBlockN(t *testing.T, n uint64, node *FullNode, blockInterval time.Du
422422func TestReadinessEndpointWhenBlockProductionStops (t * testing.T ) {
423423 require := require .New (t )
424424
425+ httpClient := & http.Client {Timeout : 1 * time .Second }
426+
425427 config := getTestConfig (t , 1 )
426428 config .Node .Aggregator = true
427429 config .Node .BlockTime = evconfig.DurationWrapper {Duration : 500 * time .Millisecond }
@@ -439,10 +441,14 @@ func TestReadinessEndpointWhenBlockProductionStops(t *testing.T) {
439441
440442 waitForBlockN (t , 1 , node , config .Node .BlockTime .Duration )
441443
442- resp , err := http .Get ("http://" + config .RPC .Address + "/health/ready" )
443- require .NoError (err )
444- require .Equal (http .StatusOK , resp .StatusCode , "Readiness should be READY while producing blocks" )
445- resp .Body .Close ()
444+ require .Eventually (func () bool {
445+ resp , err := httpClient .Get ("http://" + config .RPC .Address + "/health/ready" )
446+ if err != nil {
447+ return false
448+ }
449+ defer resp .Body .Close ()
450+ return resp .StatusCode == http .StatusOK
451+ }, 10 * time .Second , 100 * time .Millisecond , "Readiness should be READY while producing blocks" )
446452
447453 time .Sleep (time .Duration (config .Node .MaxPendingHeadersAndData + 2 ) * config .Node .BlockTime .Duration )
448454
@@ -451,7 +457,7 @@ func TestReadinessEndpointWhenBlockProductionStops(t *testing.T) {
451457 require .LessOrEqual (height , config .Node .MaxPendingHeadersAndData )
452458
453459 require .Eventually (func () bool {
454- resp , err := http .Get ("http://" + config .RPC .Address + "/health/ready" )
460+ resp , err := httpClient .Get ("http://" + config .RPC .Address + "/health/ready" )
455461 if err != nil {
456462 return false
457463 }
0 commit comments