Skip to content

Extend fuzz coverage to the escrow settlement/release path #31

Description

@Meshmulla

Background

The contract suite already uses fuzz testing, but only for a couple of areas: soroban/tests/relay_contract_fuzz.rs and soroban/tests/threshold_window_fuzz.rs, both wired into the bounded Fuzz CI job. Notably absent from fuzz coverage is the escrow settlement/release path — which is arguably the single most important flow in the whole system, because it's where value actually moves. It handles accumulation of usage/locked amounts and the settlement/release that pays it out.

Settlement logic is exactly the kind of code where example-based tests, however thorough, tend to miss things: arithmetic overflow and rounding at the boundaries, unexpected orderings of operations, and state transitions that were never anticipated. Fuzzing shines here precisely because it explores the input space a human wouldn't think to enumerate.

Why this matters

A subtle bug in settlement isn't a cosmetic issue — it's a correctness-of-funds issue. Property-style fuzzing that drives randomized sequences of operations and asserts hard invariants is one of the strongest guards available against that class of bug, and running it (bounded) on every PR means regressions are caught continuously rather than discovered after deployment.

What needs to be done

  • Add a fuzz target for the escrow settlement/release logic, structured like the existing fuzz files so it fits the established pattern.
  • Drive randomized sequences of the relevant operations (for example: record usage / lock amounts, then settle / release) over arbitrary-but-in-range inputs, and assert the invariants that must always hold, such as:
    • balances and usage counters never go negative,
    • settling drains exactly what was owed — no residue left behind, and never double-counted,
    • state transitions are always valid, and no operation panics on any input in range.
  • Wire the new target into the existing bounded Fuzz CI job with a capped iteration count, so it adds meaningful coverage without inflating CI time.

Where to look

  • soroban/tests/relay_contract_fuzz.rs, soroban/tests/threshold_window_fuzz.rs — the pattern to follow
  • soroban/src/ — the escrow / settlement modules under test
  • .github/workflows/ci.yml — the Fuzz targets (bounded) job to add the target to

Acceptance criteria

  • A fuzz target exercises the escrow settlement/release path with clearly stated invariants
  • It runs in the bounded Fuzz CI job with a capped iteration count
  • Any bug it uncovers is filed separately with a minimal reproduction
  • CI checks must be green before the PR can be merged

Notes

Keep the per-run iteration count modest so CI stays fast; a heavier nightly/scheduled sweep can be added later as its own piece of work.

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions