test(treasury): Add property and fuzz tests for treasury contract invariants#1267
Open
NUMBER72857 wants to merge 1 commit into
Open
test(treasury): Add property and fuzz tests for treasury contract invariants#1267NUMBER72857 wants to merge 1 commit into
NUMBER72857 wants to merge 1 commit into
Conversation
…ariants (MyFanss#909) - property_tests.rs: 10 proptest property tests covering 5 invariant groups - Cargo.toml: proptest = { workspace = true } added to [dev-dependencies] - Invariants verified: - deposit(x) increases balance by exactly x (for any x > 0) - deposit(≤ 0) always rejected - withdraw(x) decreases balance by exactly x (for any valid x) - balance ≥ 0 after any valid withdraw - overdraft (withdraw > balance) always rejected - withdraw(≤ 0) always rejected - deposit(x); withdraw(x) is a balance no-op for any x and any initial balance - withdraw below min_balance always rejected (for any configured min_balance) - paused deposit always rejected (any amount) - paused withdraw always rejected (any amount ≤ balance) - Tests use real TreasuryClient + StellarAssetClient — not a pure model Closes MyFanss#909
|
@NUMBER72857 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
Adds
proptest-based property tests that verify 10 treasury invariants hold for arbitrary inputs — complementing the specific-value unit tests with exhaustive randomized coverage.Changes
property_tests.rs: 10 proptest property tests across 5 invariant groupsCargo.toml:proptest = { workspace = true }added to[dev-dependencies](already a workspace dep viamyfans-token)Invariants verified
deposit(x)increases balance by exactly xprop_deposit_increases_balance_by_exact_amountdeposit(≤ 0)always rejectedprop_non_positive_deposit_always_rejectedwithdraw(x)decreases balance by exactly xprop_withdraw_decreases_balance_by_exact_amountprop_balance_non_negative_after_withdrawprop_overdraft_always_rejectedwithdraw(≤ 0)always rejectedprop_non_positive_withdraw_always_rejecteddeposit(x); withdraw(x)is a balance no-opprop_deposit_withdraw_symmetryprop_withdrawal_below_min_balance_rejectedprop_paused_deposit_always_rejectedprop_paused_withdraw_always_rejectedDesign note
Tests use real
TreasuryClient+StellarAssetClient— not a pure state model. This means property violations will manifest as the same errors callers see on-chain, not just logic failures.Closes #909