To ensure the reliability of StreamPay's accounting, we use property-based testing to verify that stream states remain consistent under any sequence of valid events.
- Conservation of Value:
deposited_amount == withdrawn_amount + escrow_balance. Funds must always be accounted for. - Non-Negativity:
deposited,withdrawn, andescrowmust never be less than zero. - Escrow Bound: A withdrawal or refund can never exceed the current
escrowbalance. - Vested Amount Bound:
0 ≤ vested_amount ≤ total_amountat all times. Vested amount can never exceed principal or go below zero. - Vested Monotonicity: As time passes, vested amount never decreases (accounting for pauses).
We use fast-check to generate randomized sequences of deposit, withdraw, and refund events.
- Runs: Default 1000 iterations per test.
- Shrinking: If a failure is found,
fast-checkautomatically simplifies the event sequence to the minimal reproduction case. - CI Stability: Tests use deterministic seeds to ensure failures are reproducible in CI pipelines.
The vested amount tests verify:
- Vested amount stays between 0 and totalAmount at any time
- Vested amount is non-decreasing with time (even with pauses)
These invariants are modeled in the frontend/middleware to guide users and catch logic errors early. However, they are not a substitute for on-chain Soroban contract security. Final enforcement always happens via Soroban smart contracts.
- Integration with StreamPay-Contracts formal verification models.
- Nightly "heavy" runs with 10,000+ iterations.