test: add negative-amount, rate-limit, deactivation, and cancel invariant tests#993
Merged
Wilfred007 merged 1 commit intoJun 29, 2026
Conversation
…iant tests orgusd (Gildado#886): - test_mint_rejects_negative_amount / test_mint_rejects_large_negative_amount - test_transfer_rejects_negative_amount / test_transfer_rejects_large_negative_amount Explicitly assert that negative (not just zero) amounts are rejected with InvalidAmount; documents the amount <= 0 guard intent for future refactors. milestone_escrow (Gildado#882, Gildado#884, Gildado#885): - test_approve_two_milestones_same_ledger_fails (Gildado#884) Confirms per-escrow LastApproveLedger throttle blocks a second approve for a *different* milestone in the same ledger. - test_release_two_milestones_same_ledger_fails (Gildado#884) Same check for release_milestone via LastReleaseLedger. - test_final_release_deactivates_escrow_when_released_equals_total (Gildado#882) Exercises the released_amount >= total_amount → is_active = false code path with a 2-milestone escrow to make the transition explicit. - test_cancel_partial_release_unreleased_amount_is_exact (Gildado#885) Asserts cancel_escrow() computes unreleased funds by summing non-released milestone amounts (not saturating_sub), so recovered == exact unreleased sum. - test_cancel_with_approved_milestones_recovers_full_unreleased (Gildado#885) Cancellation after approving-but-not-releasing returns full escrow balance.
|
@Williams-1604 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
[orgusd] [orgusd] mint() and transfer() don't explicitly reject negative amounts #886 — Adds 4 tests explicitly asserting that negative amounts (not just zero) are rejected by
mint()andtransfer()withInvalidAmount. Both-1andi128::MINare covered, making theamount <= 0guard intent future-proof against refactors that might loosen the check toamount == 0.[milestone_escrow] [milestone_escrow] No rate limit on approve/release calls across different milestones in the same ledger #884 — Adds 2 tests proving the per-escrow
LastApproveLedger/LastReleaseLedgerthrottle blocks a second action on a different milestone within the same ledger, not just a replay of the same milestone. Bothapprove_milestoneandrelease_milestoneare covered.[milestone_escrow] [milestone_escrow] No test for released_amount == total_amount while milestones remain #882 — Adds a test driving a 2-milestone escrow through the
released_amount == total_amountcode path (line 395–397 oflib.rs). The test explicitly assertsis_active = falseand verifies all funds reached the beneficiary, documenting expected behaviour for the edge-case branch.[milestone_escrow] [milestone_escrow] cancel_escrow() uses saturating_sub for unreleased_amount, which can silently lose funds accounting #885 — Adds 2 tests verifying
cancel_escrow()computesunreleased_amountby summing non-released milestone amounts (already usingchecked_add, notsaturating_sub), so the recovered amount is exact and no silent zeroing can occur on an accounting inconsistency.Test plan
cargo test -p orgusd— all orgusd tests pass (4 new + existing)cargo test -p milestone_escrow— all milestone_escrow tests pass (6 new + existing)Closes #882
Closes #884
Closes #885
Closes #886