Skip to content

Make the hdp-mcp expired-record test deterministic - #43

Merged
asiridalugoda merged 1 commit into
mainfrom
fix/mcp-expiry-test-flake
Oct 8, 2026
Merged

asiridalugoda merged 1 commit into
mainfrom
fix/mcp-expiry-test-flake

Conversation

@asiridalugoda

Copy link
Copy Markdown
Contributor

Makes the hdp-mcp test "does not treat an expired record as an integrity failure" deterministic. Test-only change.

The test waited with one setTimeout until just past header.expires_at, then asserted expires_at < Date.now(). Node timers can fire about 1 ms early, so Date.now() could equal expires_at and the strict assertion failed. This happened on public CI run 37796834941 (Node 22): expected 1791471505561 to be less than 1791471505561.

The test now waits in 1 ms steps until Date.now() is past expires_at, so the strict assertion holds by construction. What the test proves is unchanged: an expired, correctly signed record is reported through onValid, onInvalid is not called, and the handler runs.

Verification:

  • The focused test passed 200 consecutive runs on Node 22 and on Node 26, and 30 more in a separate check; the hdp-mcp suite passes (14 tests); root tests pass on Node 20 and 22.
  • With the middleware temporarily changed to report an expired token to onInvalid, the test fails (onValid not called); the change was reverted and confirmed clean before the green runs.

@asiridalugoda
asiridalugoda merged commit 2cf5685 into main Oct 8, 2026
38 checks passed
@asiridalugoda
asiridalugoda deleted the fix/mcp-expiry-test-flake branch October 8, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant