Skip to content

Conversation

0xSqualo
Copy link
Collaborator

This change introduces a basic libfuzzer style roundtrip encode/decode fuzzer to the codec crate using cargo-fuzz.

The shared FUZZING.md doc outlines the process to run the fuzzer with multiple workers, configure different options and export basic coverage information.

This approach can be used with the same harness setup across different crates.

path = ".."

[[bin]]
name = "codec"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: In other places, might there be multiple fuzz targets? Then maybe this should carry the same name as the file path for consistency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we are already in codec, I wonder if it makes sense to just call this roundtrip?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, migrated name to roundtrip in 9dbe561.

path = ".."

[[bin]]
name = "codec"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we are already in codec, I wonder if it makes sense to just call this roundtrip?

@patrick-ogrady patrick-ogrady added this to the v0.0.55 milestone Jun 16, 2025
@0xSqualo 0xSqualo marked this pull request as ready for review June 16, 2025 16:55
Cargo.toml Outdated

# Fuzz deps
libfuzzer-sys = { version = "0.4.9" }
arbitrary = { version = "1.4.1", features = ["derive"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for consistency we should:

  1. just do crate = version
  2. only specify features in the crate that is importing the shared dep

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9f629c3.

BrendanChou
BrendanChou previously approved these changes Jun 17, 2025
Copy link
Collaborator

@BrendanChou BrendanChou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @patrick-ogrady ?

@patrick-ogrady
Copy link
Contributor

LGTM, @patrick-ogrady ?

Once the lint is resolved, we can merge. Will take a look shortly.

@patrick-ogrady patrick-ogrady merged commit deb52a3 into commonwarexyz:main Jun 17, 2025
13 checks passed
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.02%. Comparing base (c46312f) to head (21ffe51).
Report is 5 commits behind head on main.

@@            Coverage Diff             @@
##             main    #1092      +/-   ##
==========================================
+ Coverage   90.99%   91.02%   +0.03%     
==========================================
  Files         191      191              
  Lines       55227    55316      +89     
==========================================
+ Hits        50255    50354      +99     
+ Misses       4972     4962      -10     

see 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c46312f...21ffe51. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants