Skip to content

Commit

Permalink
refactor(sync): simplify isExpired (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Jun 25, 2024
1 parent 41d0d7c commit 0a52c6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0a52c6e

Please sign in to comment.