test(refund-vault): add refund window boundary edge-case tests - #258
Conversation
Add three targeted tests for RefundVault refund-window boundary conditions to guard against off-by-one errors in the `>` expiry check: - `test_refund_exact_boundary_accepted`: refund at exactly `paid_at + window` succeeds (last valid ledger). - `test_refund_one_past_boundary_rejected`: refund at `paid_at + window + 1` returns `WindowExpired` (first invalid ledger). - `test_zero_window_allows_refund_after_large_advance`: window=0 bypasses the expiry check entirely, allowing refunds 10,000 ledgers later. Also fix missing closing `);` and `}` in `test_process_batch_exceeds_max_size_fails`. Refs accensa#84
|
@Orah-dev 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! 🚀 |
|
Needs review Linked to The pull request includes an out-of-scope bugfix in CHANGELOG.md and tests that are unrelated to issue #84. Reviewed commit: |
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
…anchor - Remove needless borrows in refund_internal (&env → env) where env is already &Env (clippy::needless_borrow, lib.rs:559,578) - Remove unnecessary u32 cast on ROOT_BUFFER_SIZE in receipt-anchor tests (clippy::unnecessary_cast, test.rs:744) - Apply rustfmt to long assert_eq! and chained method call in refund-vault tests (test.rs:1371,1467) 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
MergeKeeper review Scope: in scope for linked issue The pull request correctly implements all requested refund window boundary unit tests and includes minor related cleanups without modifying contract logic. Reviewed commit: |
|
MergeKeeper merge status Status: blocked Reason: One or more required CI checks failed. Failing checks:
Next steps:
|
Summary
Adds three targeted boundary edge-case tests for the
RefundVaultrefund window to guard against off-by-one errors in the>expiry check.Why
The contract checks
current_ledger > paid_at_ledger + windowto enforce the refund window. A future refactor changing>to>=, or removing the check entirely, would silently break the boundary semantics. These tests pin the exact ledger at which the window opens and closes so such regressions are caught immediately.Changes
New tests
test_refund_exact_boundary_accepted— refund at exactlypaid_at + window(the last valid ledger) succeeds. Changing>to>=would break this test.test_refund_one_past_boundary_rejected— refund atpaid_at + window + 1(the first invalid ledger) returnsWindowExpired. Removing the check entirely would break this test.test_zero_window_allows_refund_after_large_advance— whenwindow == 0, the expiry check is bypassed entirely; a refund 10,000 ledgers later still succeeds.Bugfix
);and}intest_process_batch_exceeds_max_size_fails.Contract logic under test
Testing
Closes #84