From 0a52c6e27dee0de647e95769332cc067db826e25 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Tue, 25 Jun 2024 18:39:29 +0200 Subject: [PATCH] refactor(sync): simplify isExpired (#206) --- sync/sync_head.go | 2 +- sync/sync_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sync/sync_head.go b/sync/sync_head.go index c8776552..19a2b272 100644 --- a/sync/sync_head.go +++ b/sync/sync_head.go @@ -198,7 +198,7 @@ func (s *Syncer[H]) verify(ctx context.Context, newHead H) (bool, error) { // isExpired checks if header is expired against trusting period. func isExpired[H header.Header[H]](header H, period time.Duration) bool { expirationTime := header.Time().Add(period) - return !expirationTime.After(time.Now()) + return expirationTime.Before(time.Now()) } // isRecent checks if header is recent against the given recency threshold. diff --git a/sync/sync_test.go b/sync/sync_test.go index 17b5a36e..b9acb2d3 100644 --- a/sync/sync_test.go +++ b/sync/sync_test.go @@ -43,7 +43,7 @@ func TestSyncSimpleRequestingHead(t *testing.T) { err = syncer.Start(ctx) require.NoError(t, err) - time.Sleep(time.Millisecond * 10) // needs some to realize it is syncing + time.Sleep(time.Millisecond * 100) // needs some to realize it is syncing err = syncer.SyncWait(ctx) require.NoError(t, err)