Skip to content

Add property-based tests asserting the slippage protection invariant and cooldown guard across random inputs #835

Description

@Chucks1093

Summary

The slippage protection and cooldown guard involve comparison logic that must hold for all valid input combinations. Property-based tests with randomised prices, quantities, and ledger numbers should assert these invariants never silently fail.

Scope

  • Generate random (execution_price, max_price) pairs and assert SlippageExceeded is raised iff execution_price > max_price
  • Generate random (execution_price, min_price) pairs and assert SlippageExceeded is raised iff execution_price < min_price
  • Generate random (last_buy_ledger, current_ledger, cooldown) triples and assert CooldownActive is raised iff current_ledger - last_buy_ledger < cooldown
  • Run at least 10 000 iterations per property
  • Log the reproducing seed on any invariant violation

Acceptance Criteria

  • Slippage buy invariant holds across 10 000 random inputs
  • Slippage sell invariant holds across 10 000 random inputs
  • Cooldown invariant holds across 10 000 random inputs
  • Reproducing seed logged on any violation
  • Tests run within Soroban budget limits per iteration

ETA: 24 hours


Coordinate on Telegram

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions