diff --git a/cmd/rpcdaemon/health/check_time.go b/cmd/rpcdaemon/health/check_time.go index d60452165..e78f8aee8 100644 --- a/cmd/rpcdaemon/health/check_time.go +++ b/cmd/rpcdaemon/health/check_time.go @@ -27,7 +27,7 @@ func checkTime( timestamp = int(cs) } } - if timestamp > seconds { + if timestamp < seconds { return fmt.Errorf("%w: got ts: %d, need: %d", errTimestampTooOld, timestamp, seconds) } diff --git a/cmd/rpcdaemon/health/health_test.go b/cmd/rpcdaemon/health/health_test.go index a843923ed..f46146a4f 100644 --- a/cmd/rpcdaemon/health/health_test.go +++ b/cmd/rpcdaemon/health/health_test.go @@ -245,7 +245,7 @@ func TestProcessHealthcheckIfNeeded_HeadersTests(t *testing.T) { netApiResponse: hexutil.Uint(1), netApiError: nil, ethApiBlockResult: map[string]interface{}{ - "timestamp": time.Now().Add(1 * time.Second).Unix(), + "timestamp": uint64(time.Now().Add(-10 * time.Second).Unix()), }, ethApiBlockError: nil, ethApiSyncingResult: false, @@ -264,7 +264,7 @@ func TestProcessHealthcheckIfNeeded_HeadersTests(t *testing.T) { netApiResponse: hexutil.Uint(1), netApiError: nil, ethApiBlockResult: map[string]interface{}{ - "timestamp": uint64(time.Now().Add(1 * time.Hour).Unix()), + "timestamp": uint64(time.Now().Add(-1 * time.Hour).Unix()), }, ethApiBlockError: nil, ethApiSyncingResult: false, @@ -319,7 +319,7 @@ func TestProcessHealthcheckIfNeeded_HeadersTests(t *testing.T) { netApiResponse: hexutil.Uint(10), netApiError: nil, ethApiBlockResult: map[string]interface{}{ - "timestamp": time.Now().Add(1 * time.Second).Unix(), + "timestamp": uint64(time.Now().Add(1 * time.Second).Unix()), }, ethApiBlockError: nil, ethApiSyncingResult: false,