Skip to content

feat(contract): implement cargo-fuzz testing for register and execute (#98)#132

Merged
ayomideadeniran merged 1 commit intoSoroLabs:mainfrom
MarcusDavidG:feat/fuzz-testing
Mar 29, 2026
Merged

feat(contract): implement cargo-fuzz testing for register and execute (#98)#132
ayomideadeniran merged 1 commit intoSoroLabs:mainfrom
MarcusDavidG:feat/fuzz-testing

Conversation

@MarcusDavidG
Copy link
Copy Markdown
Contributor

Summary

Closes #98

Implements fuzz testing for the SoroTask smart contract using cargo-fuzz (libFuzzer), targeting the two core functions: register and execute.

Changes

New: contract/fuzz/

  • fuzz_targets/fuzz_register.rs — drives register() with randomized interval and gas_balance bytes. Asserts that interval == 0 always panics with InvalidInterval and that any non-zero interval never causes an unexpected panic.
  • fuzz_targets/fuzz_execute.rs — drives execute() with randomized interval, ledger timestamp, and gas_balance. Catches any unexpected panics outside of the known error variants.

Modified: contract/Cargo.toml

  • Added rlib to crate-type so the fuzz harness can link against the contract as a library.

Fixed: contract/src/lib.rs

  • Fixed a pre-existing missing closing brace in resume_task() that was causing a compile error.

Updated: contract/README.md

  • Added a Fuzz Testing section documenting prerequisites, available targets, how to run locally, and how to reproduce crashes.

How to run

cd contract

# Fuzz register
cargo +nightly fuzz run fuzz_register

# Fuzz execute
cargo +nightly fuzz run fuzz_execute

# With a time limit
cargo +nightly fuzz run fuzz_register -- -max_total_time=60

…Labs#98)

- Add fuzz/fuzz_targets/fuzz_register.rs: fuzzes register() with
  randomized interval and gas_balance; asserts zero-interval always
  panics and valid intervals never panic
- Add fuzz/fuzz_targets/fuzz_execute.rs: fuzzes execute() with
  randomized interval, ledger timestamp, and gas_balance to surface
  unexpected panics in the execution path
- Add rlib to contract crate-type so the fuzz harness can link against it
- Fix pre-existing missing closing brace in resume_task()
- Document how to run fuzzers locally in contract/README.md
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@MarcusDavidG 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

@ayomideadeniran
Copy link
Copy Markdown
Contributor

Pr under review.

@ayomideadeniran ayomideadeniran merged commit 3f7f222 into SoroLabs:main Mar 29, 2026
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.

[Testing] Implement Fuzz Testing for SoroTask Smart Contract

2 participants