Skip to content

test(treasury): Add property and fuzz tests for treasury contract invariants#1267

Open
NUMBER72857 wants to merge 1 commit into
MyFanss:mainfrom
NUMBER72857:feat/909-treasury-property-fuzz-tests
Open

test(treasury): Add property and fuzz tests for treasury contract invariants#1267
NUMBER72857 wants to merge 1 commit into
MyFanss:mainfrom
NUMBER72857:feat/909-treasury-property-fuzz-tests

Conversation

@NUMBER72857
Copy link
Copy Markdown

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 groups
  • Cargo.toml: proptest = { workspace = true } added to [dev-dependencies] (already a workspace dep via myfans-token)

Invariants verified

Invariant Test
deposit(x) increases balance by exactly x prop_deposit_increases_balance_by_exact_amount
deposit(≤ 0) always rejected prop_non_positive_deposit_always_rejected
withdraw(x) decreases balance by exactly x prop_withdraw_decreases_balance_by_exact_amount
balance ≥ 0 after any valid withdraw prop_balance_non_negative_after_withdraw
overdraft always rejected prop_overdraft_always_rejected
withdraw(≤ 0) always rejected prop_non_positive_withdraw_always_rejected
deposit(x); withdraw(x) is a balance no-op prop_deposit_withdraw_symmetry
withdraw below min_balance always rejected prop_withdrawal_below_min_balance_rejected
paused deposit always rejected prop_paused_deposit_always_rejected
paused withdraw always rejected prop_paused_withdraw_always_rejected

Design 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

…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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

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

Learn more about application limits

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.

Contract treasury: Add property or fuzz test for invariants

1 participant