📌 Description
total_fees_accrued sums fees_accrued(asset) across list_assets, and fees_accrued(asset) is meant to track the fee portion of every execute_settlement call for that asset since the last collect_fees. There is no property-style test asserting this invariant holds under a randomized mix of open_settlement/execute_settlement/cancel_settlement/collect_fees calls across multiple assets and anchors, only more targeted example-based tests elsewhere in the suite.
🧩 Requirements and context
- Add a
proptest-based test (the crate already depends on proptest per Cargo.toml) generating a randomized sequence of open_settlement, execute_settlement, cancel_settlement, and collect_fees calls across a small fixed set of assets and anchors.
- Independently track, in the test itself, the expected accrued-fee total per asset from every
execute_settlement call minus every collect_fees call, and assert it matches total_fees_accrued/fees_accrued(asset) after each step.
- Ensure the generated sequence respects preconditions (sufficient liquidity, valid settlement ids, registered anchors) so the property test explores valid executions rather than mostly hitting early validation errors.
🛠️ Suggested execution
- Add the proptest to
src/test.rs, reusing the crate's existing proptest dev-dependency and any strategy helpers already present for other property tests in this suite.
- Keep the state-machine model simple: track a
HashMap<Symbol, i128> of expected accrued fees, mutated alongside each simulated call, and assert equality with the contract's on-chain state after each step.
- Document the invariant being tested in a comment above the proptest for future maintainers.
✅ Acceptance criteria
🔒 Security notes
Fee accrual drift compounding silently across many settlements is exactly the class of bug example-based tests are least likely to catch; a property test covering the full accrual/collection lifecycle is the strongest guard against a subtle fund-accounting regression here.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
total_fees_accruedsumsfees_accrued(asset)acrosslist_assets, andfees_accrued(asset)is meant to track the fee portion of everyexecute_settlementcall for that asset since the lastcollect_fees. There is no property-style test asserting this invariant holds under a randomized mix ofopen_settlement/execute_settlement/cancel_settlement/collect_feescalls across multiple assets and anchors, only more targeted example-based tests elsewhere in the suite.🧩 Requirements and context
proptest-based test (the crate already depends onproptestperCargo.toml) generating a randomized sequence ofopen_settlement,execute_settlement,cancel_settlement, andcollect_feescalls across a small fixed set of assets and anchors.execute_settlementcall minus everycollect_feescall, and assert it matchestotal_fees_accrued/fees_accrued(asset)after each step.🛠️ Suggested execution
src/test.rs, reusing the crate's existingproptestdev-dependency and any strategy helpers already present for other property tests in this suite.HashMap<Symbol, i128>of expected accrued fees, mutated alongside each simulated call, and assert equality with the contract's on-chain state after each step.✅ Acceptance criteria
fees_accrued/total_fees_accruedto drift from the sum of actually-executed settlement fees.Cargo.toml's existingproptestdependency without requiring a new one.🔒 Security notes
Fee accrual drift compounding silently across many settlements is exactly the class of bug example-based tests are least likely to catch; a property test covering the full accrual/collection lifecycle is the strongest guard against a subtle fund-accounting regression here.
📋 Guidelines