Skip to content

Add property-based fuzz tests for stream financial invariants #367

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

All stream tests use handpicked values. Fuzzing with random inputs is the most effective way to catch edge cases in the streaming math before mainnet deployment.

Invariants to Fuzz

  • withdrawn <= deposited — recipient never receives more than deposited
  • claimable <= (deposited - withdrawn) — claimable never exceeds remaining
  • cancel_refund + amount_withdrawn <= deposited — total payout never exceeds deposit
  • Accrual after multiple pause/resume cycles equals sum of active-period durations × rate
  • After protocol fee: net_deposited == gross × (1 - fee_rate_bps / 10_000)

Use soroban-sdk testutils with random amount (1..i128::MAX/2), duration (1..u32::MAX), varied pause points.

Files

  • contracts/stream_contract/src/test.rs

Acceptance Criteria

  • Fuzz tests cover all 5 invariants
  • 10,000+ iterations with no violation
  • cargo test clean

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programsmart-contractSoroban smart contracttestingTesting related tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions