Skip to content

test: fuzz weighted distribute#619

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
pimaster900:task/fuzz-weighted-dist
Jun 29, 2026
Merged

test: fuzz weighted distribute#619
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
pimaster900:task/fuzz-weighted-dist

Conversation

@pimaster900

Copy link
Copy Markdown
Contributor

test: fuzz weighted distribute

Adds a cargo-fuzz target for batch_distribute in the revenue pool contract.

What's new

  • contracts/revenue_pool/fuzz/Cargo.toml — fuzz crate wired to libfuzzer-sys
  • contracts/revenue_pool/fuzz/targets/weighted_distribute.rs — fuzz target that decodes raw
    bytes into weighted payment legs and asserts three invariants on every execution:
    1. Conservation — on success, pool balance decreases by exactly the sum of distributed
      amounts
    2. Rejection invariant — on any invalid input (zero amount, duplicate recipient, oversized
      batch, insufficient balance), balance is unchanged
    3. No uncontrolled panic — unexpected aborts surface as fuzzer failures

Encoding

Input bytes are parsed as 3-byte legs: 1 byte selects a developer from a fixed pool of 8
addresses (naturally produces duplicate-recipient cases), 2 bytes encode the u16 amount
(naturally produces zero-amount cases). No manual corpus seeding required.

Running

cargo install cargo-fuzz
cd contracts/revenue_pool
cargo fuzz run weighted_distribute

Workspace impact

Fuzz crate added to workspace.members but not default-members — cargo build and cargo test at
the root are unaffected.

closes #540

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@pimaster900 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit 0621b39 into CalloraOrg:main Jun 29, 2026
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fuzz target for batch_distribute under unequal weights

2 participants