Add simple fuzz tests for hashing and boolean-bitfield

This commit is contained in:
Kirk Baird 2019-02-22 16:50:14 +11:00
parent fdbd9d4410
commit ab1dc7bfce
No known key found for this signature in database
GPG Key ID: BF864B7ED0BEA33F
8 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,4 @@
target
corpus
artifacts

View File

@ -0,0 +1,33 @@
[package]
name = "boolean-bitfield-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies]
ssz = { path = "../../ssz" }
[dependencies.boolean-bitfield]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "fuzz_target_from_bytes"
path = "fuzz_targets/fuzz_target_from_bytes.rs"
[[bin]]
name = "fuzz_target_ssz_decode"
path = "fuzz_targets/fuzz_target_ssz_decode.rs"
[[bin]]
name = "fuzz_target_ssz_encode"
path = "fuzz_targets/fuzz_target_ssz_encode.rs"

View File

@ -0,0 +1,9 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate boolean_bitfield;
use boolean_bitfield::BooleanBitfield;
fuzz_target!(|data: &[u8]| {
let _result = BooleanBitfield::from_bytes(data);
});

View File

@ -0,0 +1,11 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate boolean_bitfield;
extern crate ssz;
use boolean_bitfield::BooleanBitfield;
use ssz::{Decodable, DecodeError};
fuzz_target!(|data: &[u8]| {
let result: Result<(BooleanBitfield, usize), DecodeError> = <_>::ssz_decode(data, 0);
});

View File

@ -0,0 +1,13 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate boolean_bitfield;
extern crate ssz;
use boolean_bitfield::BooleanBitfield;
use ssz::SszStream;
fuzz_target!(|data: &[u8]| {
let bitfield = BooleanBitfield::from_bytes(data);
let mut ssz = SszStream::new();
ssz.append(&bitfield);
});

4
eth2/utils/hashing/fuzz/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
target
corpus
artifacts

View File

@ -0,0 +1,22 @@
[package]
name = "hashing-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies.hashing]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "fuzz_target_hash"
path = "fuzz_targets/fuzz_target_hash.rs"

View File

@ -0,0 +1,9 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate hashing;
use hashing::hash;
fuzz_target!(|data: &[u8]| {
let _result = hash(data);
});