Skip to content

test(idempotency): use consistent timestamp units in unit test fixtures - #5883

Merged
dreamorosi merged 2 commits into
mainfrom
test/idempotency-fixture-timestamp-units
Oct 31, 2026
Merged

dreamorosi merged 2 commits into
mainfrom
test/idempotency-fixture-timestamp-units

Conversation

@dreamorosi

Copy link
Copy Markdown
Contributor

Summary

IdempotencyRecord.isExpired() compares expiryTimestamp with Date.now() / 1000, so the value is in seconds, but several unit test fixtures set it in milliseconds. The tests passed only because a millisecond value read as seconds is always far in the future. This is the same kind of fixture/code mismatch that hid the bug fixed in #5881. This PR changes those fixtures to seconds and rewrites misleading timestamp comments. It only touches tests; runtime behaviour doesn't change.

Changes

  • packages/idempotency/tests/unit/IdempotencyHandler.test.ts
    • Change expiryTimestamp fixtures from milliseconds to seconds (Date.now() / 1000 + 1, Date.now() / 1000 + 10)
    • Reword the inProgressExpiryTimestamp: 0 comments: 0 means there is no in-progress deadline, so determineResultFromIdempotencyRecord() skips the expiry check
    • Add seconds/milliseconds unit comments to the timestamps in the throws when the record is in progress and outside expiry window and retries and runs the function when the in-progress record has an expired deadline tests
  • packages/idempotency/tests/unit/makeIdempotent.test.ts
    • Change all 9 expiryTimestamp fixtures from milliseconds to seconds; inProgressExpiryTimestamp stays in milliseconds

Unit tests pass with 100% coverage.

Issue number: closes #5882


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

IdempotencyRecord.isExpired() reads expiryTimestamp in seconds, but several fixtures
set it in milliseconds. They passed only because a millisecond value read as seconds
is always far in the future. Switch them to seconds and clarify the unit and intent
of the related timestamp comments.

Fixes #5882
@dreamorosi
dreamorosi enabled auto-merge (squash) October 31, 2026 18:02
@dreamorosi
dreamorosi merged commit 4c73c31 into main Oct 31, 2026
41 checks passed
@dreamorosi
dreamorosi deleted the test/idempotency-fixture-timestamp-units branch October 31, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M PR between 30-99 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: use consistent timestamp units in idempotency unit test fixtures

2 participants