Add property-based tests asserting refunds never exceed total funded principal
Description
In a cancelled escrow, the sum of all per-investor refunds must never exceed funded_amount, and DistributedPrincipal must converge to exactly the total contributed when every investor refunds. The existing proptest suite covers payout rounding and the dust floor, but there is no property asserting the global refund conservation invariant across arbitrary investor sets and refund orderings.
This issue adds a proptest invariant for refund conservation.
Requirements and context
- Repository scope: Liquifact/Liquifact-contracts only.
- Generate arbitrary sets of investors with arbitrary contributions, fund, cancel, then refund in arbitrary order.
- Assert
sum(refunds) == sum(contributions) once all investors refund, and DistributedPrincipal equals that sum.
- Assert no single refund exceeds the investor's recorded contribution and double-refund is impossible.
- Assert the contract token balance never goes negative during the refund sequence.
- Seed any discovered failing case into
escrow/proptest-regressions.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-refund-conservation-proptest
- Implement changes
- Write code in: no production change expected; if a defect is found, fix it in
contracts/escrow/src/lib.rs.
- Write comprehensive tests in:
contracts/escrow/src/tests/properties.rs — the refund-conservation invariant.
- Add documentation: note the conservation invariant in
README.md and docs/.
- Include NatSpec-style doc comments (
///) on the property and its assumptions.
- Validate security assumptions: no ordering of refunds can over-distribute principal.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases and failure paths: single investor, many investors, reverse-order refunds, and partial refunds.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
test: add proptest invariant asserting refunds never exceed funded principal
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Add property-based tests asserting refunds never exceed total funded principal
Description
In a cancelled escrow, the sum of all per-investor refunds must never exceed
funded_amount, andDistributedPrincipalmust converge to exactly the total contributed when every investor refunds. The existing proptest suite covers payout rounding and the dust floor, but there is no property asserting the global refund conservation invariant across arbitrary investor sets and refund orderings.This issue adds a proptest invariant for refund conservation.
Requirements and context
sum(refunds) == sum(contributions)once all investors refund, andDistributedPrincipalequals that sum.escrow/proptest-regressions.Suggested execution
git checkout -b test/contracts-refund-conservation-proptestcontracts/escrow/src/lib.rs.contracts/escrow/src/tests/properties.rs— the refund-conservation invariant.README.mdanddocs/.///) on the property and its assumptions.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput and a short security notes section in the PR description.Example commit message
test: add proptest invariant asserting refunds never exceed funded principalGuidelines
Community & contribution rewards