Skip to content

Commit

Permalink
fuzzers
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 10, 2022
1 parent 74d1e3e commit abfe104
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ jobs:
run: |
cd clvm-utils
cargo +nightly fuzz build
- name: cargo fuzz (chia-protocol)
run: |
cd chia-protocol
cargo +nightly fuzz build
unit_tests:
runs-on: ${{ matrix.os }}
Expand Down
49 changes: 49 additions & 0 deletions chia-protocol/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "chia-protocol-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.chia-protocol]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "parse-full-block"
path = "fuzz_targets/parse-full-block.rs"
test = false
doc = false

[[bin]]
name = "parse-header-block"
path = "fuzz_targets/parse-header-block.rs"
test = false
doc = false

[[bin]]
name = "parse-foliage"
path = "fuzz_targets/parse-foliage.rs"
test = false
doc = false

[[bin]]
name = "parse-tx-info"
path = "fuzz_targets/parse-tx-info.rs"
test = false
doc = false

[[bin]]
name = "parse-program"
path = "fuzz_targets/parse-program.rs"
test = false
doc = false
9 changes: 9 additions & 0 deletions chia-protocol/fuzz/fuzz_targets/parse-foliage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::io::Cursor;
use chia_protocol::Foliage;
use chia_protocol::Streamable;

fuzz_target!(|data: &[u8]| {
let _ret = <Foliage as Streamable>::parse(&mut Cursor::<&[u8]>::new(data));
});
9 changes: 9 additions & 0 deletions chia-protocol/fuzz/fuzz_targets/parse-full-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::io::Cursor;
use chia_protocol::FullBlock;
use chia_protocol::Streamable;

fuzz_target!(|data: &[u8]| {
let _ret = <FullBlock as Streamable>::parse(&mut Cursor::<&[u8]>::new(data));
});
9 changes: 9 additions & 0 deletions chia-protocol/fuzz/fuzz_targets/parse-header-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::io::Cursor;
use chia_protocol::HeaderBlock;
use chia_protocol::Streamable;

fuzz_target!(|data: &[u8]| {
let _ret = <HeaderBlock as Streamable>::parse(&mut Cursor::<&[u8]>::new(data));
});
9 changes: 9 additions & 0 deletions chia-protocol/fuzz/fuzz_targets/parse-program.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::io::Cursor;
use chia_protocol::Program;
use chia_protocol::Streamable;

fuzz_target!(|data: &[u8]| {
let _ret = <Program as Streamable>::parse(&mut Cursor::<&[u8]>::new(data));
});
9 changes: 9 additions & 0 deletions chia-protocol/fuzz/fuzz_targets/parse-tx-info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::io::Cursor;
use chia_protocol::TransactionsInfo;
use chia_protocol::Streamable;

fuzz_target!(|data: &[u8]| {
let _ret = <TransactionsInfo as Streamable>::parse(&mut Cursor::<&[u8]>::new(data));
});

0 comments on commit abfe104

Please sign in to comment.