feat(onchain): add proptest invariant suite for crowdfund_vault#440
Open
Johnsmichael150 wants to merge 2 commits intoPulsefy:mainfrom
Open
feat(onchain): add proptest invariant suite for crowdfund_vault#440Johnsmichael150 wants to merge 2 commits intoPulsefy:mainfrom
Johnsmichael150 wants to merge 2 commits intoPulsefy:mainfrom
Conversation
- Add proptest = "1" to crowdfund_vault dev-dependencies - Add tests/invariants.rs with 5 property-based tests (1000 cases each): - Property 1: balance equals sum of contributions (Req 1.1, 1.5) - Property 4: contribution tracking round-trip (Req 2.1) - Property 7: overdraft is rejected (Req 3.1) - Property 9: single-contributor match approximation (Req 4.2) - Property 11: paused contract blocks all mutations (Req 5.1-5.3) - Update apps/onchain/.gitignore to exclude proptest snapshot JSON files - Add spec files: .kiro/specs/invariant-hardening/
|
@Johnsmichael150 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! 🚀 |
Contributor
|
Please fix failing workflow |
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.
feat(onchain): Add proptest invariant suite for
crowdfund_vaultSummary
Introduces a property-based test suite (
tests/invariants.rs) for thecrowdfund_vaultSoroban smart contract using theproptestcrate. All changes are in the test layer — no production code was modified.Motivation
Hand-written unit tests in
src/test.rscover specific examples but cannot exhaustively explore the input space. Property-based testing generates thousands of randomized scenarios to verify that core protocol invariants hold regardless of input, catching edge cases that example-based tests miss.Changes
New file:
apps/onchain/contracts/crowdfund_vault/tests/invariants.rsFive property tests, each running 1000 cases:
prop_balance_equals_sum_of_contributionsprop_contribution_trackingprop_overdraftprop_single_contributor_matchprop_paused_blocks_mutationsModified:
apps/onchain/contracts/crowdfund_vault/Cargo.tomlAdded
proptest = "1"to[dev-dependencies].Modified:
apps/onchain/.gitignoreExcluded proptest-generated snapshot JSON files (
**/test_snapshots/prop_*.json,**/test_snapshots/scaffold_*.json) to keep the repo clean.How to run
Expected output: 6 tests pass (1 scaffold smoke test + 5 property tests).
Test coverage
get_balance == Σ amountsandtotal_deposited == Σ amounts.get_contribution == prior + amount.try_withdraw(D + E)returns an error and balance remains D.calculate_matchis within 1% of C (fixed-point rounding tolerance forsqrt_scaled).try_deposit,try_create_project, andtry_withdrawall returnContractPausedand no state changes.Notes
proptest!block constructs a freshEnvinside the closure because Soroban'sEnvis notSend.Close #429