Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sync): simplify isExpired #206

Merged
merged 9 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading