test: add clock-rollover regression tests at u64 boundary#1677
Open
senmalong wants to merge 2 commits into
Open
test: add clock-rollover regression tests at u64 boundary#1677senmalong wants to merge 2 commits into
senmalong wants to merge 2 commits into
Conversation
…#1585) Cover behaviour at u64::MAX - 1, u64::MAX, and after a simulated rollover back to 0 for all time-sensitive contract paths: - Invoice::is_overdue – not overdue at exact u64::MAX; safe after rollover to 0 - Invoice::grace_deadline – saturating_add never wraps at u64::MAX boundary - Bid::default_expiration – saturates to u64::MAX when now is near MAX - Bid::is_expired – strict > semantics preserved at u64::MAX and post-rollover - store_invoice (contract) – accepted at NEAR_MAX ledger / u64::MAX due_date; rejected when due_date == now == u64::MAX - upload_invoice + place_bid (contract) – expiration_timestamp saturated when placed at u64::MAX - 1; cleanup leaves the bid intact at exact boundary 18 deterministic unit and integration tests, no std calls, no Date.now() / Math.random(). All tests run in default cargo test (not behind a feature flag). Closes QuickLendX#1585
|
@senmalong Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the regression test suite requested in issue #1585. Adds
quicklendx-contracts/src/test_clock_rollover.rsand wires it intolib.rswith#[cfg(test)](always-on, no feature flag required).What is covered
Invoice::is_overdueu64::MAX; safe after rollover to 0due_dateis small and clock is near MAXInvoice::grace_deadlineu64::MAXfrom near-MAXdue_dateInvoice::grace_deadlinedue_date == u64::MAXand any grace period > 0Bid::default_expirationu64::MAXBid::is_expiredu64::MAXboundaryu64::MAX - 1ledger /u64::MAXdue_datedue_date == now == u64::MAXu64::MAX18 tests total — 8 pure-logic (no contract round-trip) and 10 integration (full contract calls).
Design decisions
env.ledger().set_timestamp()andenv.as_contract(). NoDate::now()or random values.invoice_not_overdue_when_due_date_equals_u64_max.#[cfg(test)], not behindlegacy-testsorfuzz-tests, so it runs on every CI matrix entry.Pre-existing failures
The codebase already has 22 compilation errors in unrelated files (
verification.rs,lib.rs,test_invoice_search_ranking.rs,types.rs). These are not introduced by this PR and blockcargo testfor all tests on the current branch; they will need to be fixed separately.Testing
Closes #1585