Skip to content

test(refund-vault): add refund window boundary edge-case tests - #258

Merged
mallison031 merged 5 commits into
accensa:mainfrom
Orah-dev:test/refund-window-boundaries
Aug 30, 2026
Merged

test(refund-vault): add refund window boundary edge-case tests#258
mallison031 merged 5 commits into
accensa:mainfrom
Orah-dev:test/refund-window-boundaries

Conversation

@Orah-dev

Copy link
Copy Markdown
Contributor

Summary

Adds three targeted boundary edge-case tests for the RefundVault refund window to guard against off-by-one errors in the > expiry check.

Why

The contract checks current_ledger > paid_at_ledger + window to 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 exactly paid_at + window (the last valid ledger) succeeds. Changing > to >= would break this test.
  • test_refund_one_past_boundary_rejected — refund at paid_at + window + 1 (the first invalid ledger) returns WindowExpired. Removing the check entirely would break this test.
  • test_zero_window_allows_refund_after_large_advance — when window == 0, the expiry check is bypassed entirely; a refund 10,000 ledgers later still succeeds.

Bugfix

  • Fixed missing closing ); and } in test_process_batch_exceeds_max_size_fails.

Contract logic under test

if window > 0 {
    let current_ledger = env.ledger().sequence();
    if current_ledger > paid_at_ledger + window {
        return Err(Error::WindowExpired);
    }
}

Testing

  • All new tests are deterministic and use explicit ledger sequence manipulation.
  • Each test is documented with the invariant it protects.

Closes #84

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
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@mergekeeper

mergekeeper Bot commented Aug 28, 2026

Copy link
Copy Markdown

Needs review

Linked to #84, but the diff does not match the issue scope.

The pull request includes an out-of-scope bugfix in CHANGELOG.md and tests that are unrelated to issue #84.

Reviewed commit: b9737e46e797ea706b6b3e1a8ed49074127ae984.

Orah-dev and others added 2 commits August 28, 2026 14:45
🤖 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

mergekeeper Bot commented Aug 28, 2026

Copy link
Copy Markdown

MergeKeeper review

Scope: in scope for linked issue #84.
Verdict: clean

The pull request correctly implements all requested refund window boundary unit tests and includes minor related cleanups without modifying contract logic.

Reviewed commit: 07d51e11689f634f84bd3225fc2a18a47f2f1db1.
CI and merge eligibility are checked separately.

@mergekeeper

mergekeeper Bot commented Aug 28, 2026

Copy link
Copy Markdown

MergeKeeper merge status

Status: blocked
PR state: open
Mergeability: unknown
Checked commit: 07d51e11689f634f84bd3225fc2a18a47f2f1db1.

Reason: One or more required CI checks failed.

Failing checks:

Next steps:

  1. Open the failing check details above and fix the reported error.
  2. Run the same checks locally where possible.
  3. Commit and push the fix.
  4. MergeKeeper will automatically re-review the updated PR.

@mallison031
mallison031 merged commit 9ce83af into accensa:main Aug 30, 2026
2 of 6 checks passed
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.

test(contracts): add tests for refund window boundary edge cases

3 participants