Skip to content

Settlement: add property-based test that sum of credits equals pool plus developer totals #345

@greatest0fallt1me

Description

@greatest0fallt1me

Description

CalloraSettlement tracks a GlobalPool.total_balance and per-developer balances independently. There is no invariant test proving that the sum of all receive_payment amounts equals pool total + sum of developer balances. Add a randomized/property-style test in contracts/settlement/src/test.rs to catch accounting drift.

Requirements and Context

  • Drive many randomized receive_payment calls (mix of to_pool=true/false) and assert the conservation invariant.
  • Include overflow-boundary credits near i128::MAX.
  • Add the invariant to INVARIANTS.md.
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b task/settlement-conservation-invariant
  2. Implement changes
    • contracts/settlement/src/test.rs — invariant/property test
    • INVARIANTS.md — document the conservation invariant
  3. Test and commit
    • cargo test -p callora-settlement
    • Cover overflow boundary
    • Include test output and notes in the PR

Example commit message

test: assert settlement credit conservation invariant

Acceptance Criteria

  • Conservation invariant tested over many randomized credits
  • Overflow boundary covered
  • Invariant documented in INVARIANTS.md
  • Tests pass

Guidelines

  • .rs under contracts/settlement/src/, cargo test, /// docs, minimum 95% line coverage, no unwrap() in prod paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programauditSecurity audit/reviewsmart-contractSoroban smart-contract worktestingTests and coverage

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions