You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The platform moves real member funds across eight Soroban contracts (factory, rotational, flexible, target, microloan, governance, reputation, yield-strategy), yet only one of them — rotational — has fuzz tests today (smartcontract/contracts/rotational/src/fuzz_tests.rs). The rest rely on unit tests that exercise fixed happy and edge paths.
Fee math, round-shifting, loan interest and repayment, governance quorum thresholds, and reputation accounting are exactly the kinds of integer-heavy, stateful logic that dedicated property / invariant testing is built for. This issue asks for a systematic fuzz + invariant testing pass across the contract suite.
Requirements
Invariant tests per contract covered by the Soroban testutils fuzzer (the same harness rotational/src/fuzz_tests.rs uses). For each contract, define and assert invariants that must hold for any sequence of operations:
rotational (extend what exists): total contributed = sum of member contributions at all times for a round; treasury/relayer fees never exceed deposited amounts; payout always ≤ pool balance; only the current eligible member can receive a slot's payout.
flexible / target: aggregate balance reconciliation; withdrawals capped by balances and minimum-deposit rules.
microloan: total_owed and remaining are always consistent with principal + interest and are never negative; repaid amount never exceeds owed; a repaid/defaulted loan transitions correctly (no double-repay, no withdraw of others' funds).
governance: quorum and against-threshold math; at most MAX_ACTIVE_PROPOSALS active; a veto/decision can never be registered twice.
reputation: scores never overflow i128; a member's score is bounded between its floor and the values the redemptions allow.
yield-strategy: shares vs. underlying reconciliation (share price can never go negative or be manipulated to zero).
Multi-round / multi-call fuzz scenarios — sequence random valid calls (deposit, payout, withdraw, remove_member, add_member, delete round, emergency paths) for thousands of iterations and assert no panic, no invariant break, and no funds created or destroyed.
Boundary / overflow focus — exercise the fee bps (0 → 10000), round durations, member counts at limits, and asset amount extremes (0, 1, i128::MAX) to catch integer overflow/underflow panics that unit tests miss.
Deterministic + CI — make fuzz runs reproducible (fixed seed or captured case) and register them in the CI workflow so a discovered counterexample fails the build. Include the seed/hash of any found counterexample in the failure output for reproduction.
Notes / context
Reuse the existing harness pattern in rotational/src/fuzz_tests.rs as the reference implementation and extend it to the other contracts.
Prioritize microloan and yield-strategy first — they have the most fee/interest/redemption arithmetic and the least direct coverage.
Do not change contract behavior as a side effect; the goal is to prove the current arithmetic is safe (and fix any real bug found, with a regression test).
Invariant tests exist and pass for at least the four highest-value contracts (microloan, yield-strategy, governance, flexible/target) and extend existing rotational coverage
Multi-call fuzz scenarios run thousands of iterations without panic or invariant break
Boundary/overflow cases explicitly covered
Fuzz runs are deterministic and wired into CI with a reproduction seed on failure
Any real bug found has a regression test and a documented fix
Summary
The platform moves real member funds across eight Soroban contracts (
factory,rotational,flexible,target,microloan,governance,reputation,yield-strategy), yet only one of them —rotational— has fuzz tests today (smartcontract/contracts/rotational/src/fuzz_tests.rs). The rest rely on unit tests that exercise fixed happy and edge paths.Fee math, round-shifting, loan interest and repayment, governance quorum thresholds, and reputation accounting are exactly the kinds of integer-heavy, stateful logic that dedicated property / invariant testing is built for. This issue asks for a systematic fuzz + invariant testing pass across the contract suite.
Requirements
Invariant tests per contract covered by the Soroban
testutilsfuzzer (the same harnessrotational/src/fuzz_tests.rsuses). For each contract, define and assert invariants that must hold for any sequence of operations:total_owedandremainingare always consistent with principal + interest and are never negative; repaid amount never exceeds owed; a repaid/defaulted loan transitions correctly (no double-repay, no withdraw of others' funds).MAX_ACTIVE_PROPOSALSactive; a veto/decision can never be registered twice.Multi-round / multi-call fuzz scenarios — sequence random valid calls (deposit, payout, withdraw, remove_member, add_member, delete round, emergency paths) for thousands of iterations and assert no panic, no invariant break, and no funds created or destroyed.
Boundary / overflow focus — exercise the fee bps (0 → 10000), round durations, member counts at limits, and asset amount extremes (0, 1,
i128::MAX) to catch integer overflow/underflow panics that unit tests miss.Deterministic + CI — make fuzz runs reproducible (fixed seed or captured case) and register them in the CI workflow so a discovered counterexample fails the build. Include the seed/hash of any found counterexample in the failure output for reproduction.
Notes / context
rotational/src/fuzz_tests.rsas the reference implementation and extend it to the other contracts.microloanandyield-strategyfirst — they have the most fee/interest/redemption arithmetic and the least direct coverage.Acceptance criteria
microloan,yield-strategy,governance,flexible/target) and extend existingrotationalcoverage