Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ on:
pull_request:

jobs:
test:
name: Test Fuzz Library
if: ${{ !github.event.act }}
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4

- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run Tests
run: cargo test -p simplicity-fuzz --lib

fuzz:
name: Run Fuzz Target
if: ${{ !github.event.act }}
Expand All @@ -23,6 +37,7 @@ c_rust_merkle,
decode_natural,
decode_program,
parse_human,
prune_generated,
regression_286,
regression_value,
]
Expand Down
1 change: 1 addition & 0 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ dependencies = [
name = "simplicity-fuzz"
version = "0.0.1"
dependencies = [
"arbitrary",
"base64 0.22.1",
"libfuzzer-sys",
"simplicity-lang 0.3.1",
Expand Down
8 changes: 8 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cargo-fuzz = true
path = "fuzz_lib/lib.rs"

[dependencies]
arbitrary = "1.4.2"
libfuzzer-sys = "0.4"
# We shouldn't need an explicit version on the next line, but Andrew's tools
# choke on it otherwise. See https://github.com/nix-community/crate2nix/issues/373
Expand Down Expand Up @@ -67,6 +68,13 @@ test = false
doc = false
bench = false

[[bin]]
name = "prune_generated"
path = "fuzz_targets/prune_generated.rs"
test = false
doc = false
bench = false

[[bin]]
name = "regression_286"
path = "fuzz_targets/regression_286.rs"
Expand Down
8 changes: 7 additions & 1 deletion fuzz/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ rustc --version
# Run fuzz target
for targetFile in $targetFiles; do
targetName=$(targetFileToName "$targetFile")
cargo-fuzz run "$targetName" -- -max_total_time=30
# prune_generated builds a program from its input, and only long inputs give
# large programs, which libFuzzer otherwise tries only after a long time.
extraArgs=()
if [ "$targetName" == "prune_generated" ]; then
extraArgs=(-len_control=0 -max_len=4096)
fi
cargo-fuzz run "$targetName" -- -max_total_time=30 "${extraArgs[@]}"
done
Loading
Loading