Skip to content

test(protocol): bracket the custody acceptance clock in the expiry test - #494

Merged
bahdotsh merged 1 commit into
mainfrom
fix/custody-expiry-test-clock
Sep 30, 2026
Merged

bahdotsh merged 1 commit into
mainfrom
fix/custody-expiry-test-clock

Conversation

@bahdotsh

Copy link
Copy Markdown
Member

a_held_frame_expires_at_the_end_of_the_hold_in_force (from #493) flakes on loaded CI runners. It failed on Windows (#485) and macOS (#487) on 2026-10-01, both PRs that do not touch custody.

Cause

The engine stamps accepted_at_ms from the wall clock at the drop point. The test read Utc::now() only after acceptance and then swept at now_ms + hold - 1. Expiry is now - accepted > hold, so two milliseconds between acceptance and the test's read put the "inside the hold" sweep past the hold.

Fix

Read the clock before and after acceptance. The inside sweep runs at before_ms + hold, which is never more than hold past acceptance. The expiry sweep runs at after_ms + hold + 1, which is always past it. Test-only change.

Verification

  • A 5 ms sleep injected after acceptance fails the original test (inside the hold, custody.rs:639) and passes the fixed one.
  • The fixed test passes as committed. cargo fmt --all -- --check is clean.

The engine stamps a held frame's acceptance with the wall clock, and the
test read its own clock only afterwards, then swept at that reading plus
the hold minus one. Expiry is `now - accepted > hold`, so two milliseconds
between acceptance and the read put the "inside the hold" sweep past it.
A loaded CI runner failed it on Windows and macOS on the same day.

Read the clock before and after acceptance: the inside sweep uses the
earlier reading, the expiry sweep the later one, so neither depends on
how long the runner took.
@bahdotsh
bahdotsh merged commit 24ebe9d into main Sep 30, 2026
22 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant