Skip to content

Property-based tests: cascade payouts always sum to amount #16

Open

Description

@SYMBAxx

Add randomized tests (e.g. proptest in dev-deps) generating random split graphs (incl. cycles) and amounts, asserting conservation of funds and depth ≤ 3.

Acceptance: runs in CI under 30s.

Activity

  1. NePreby commented on Nov 9, 2026

    @NePreby

    I have implemented comprehensive property-based tests verifying conservation of funds, depth bounds, and cycle termination for CascadeSplitter:

    Summary of Coverage

    1. Randomized Split Graphs & Invariants:
      • Added proptest = "1.6" to dev-dependencies in contracts/cascade_splitter/Cargo.toml.
      • Added property-based tests in contracts/cascade_splitter/src/test.rs generating randomized multi-node split graphs with varying allocations, basis points, and amounts up to $10^{15}$.
      • Verified that total settled payouts identically equal the initial amount (sum == amount) across all divisions and dust settlements.
      • Verified that every payout satisfies depth <= 3 (MAX_DEPTH) and amount > 0.
      • Verified actual token distribution on-chain transfers sum exactly to amount and debit the payer by amount.
    2. Cyclic Graph Termination:
      • Explicitly validated 2-node mutual cycles ($A \leftrightarrow B$), 3-node cyclic rings ($A \to B \to C \to A$), and dense multigraph cycles, asserting deterministic termination and conservation of funds.
    3. Deep Linear Cascades:
      • Validated that cascading through 6 hops strictly settles at depth 3 without recursing deeper.
    4. CI Runtime:
      • All property test cases execute in just a few seconds, well below the 30-second CI threshold.

    Payout Details

    • Network: TRX Tron (TRC20)
    • Address: TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions