Skip to content

Commit

Permalink
Support protocol version 1 and 2 in fuzz targets (mimblewimble#3073)
Browse files Browse the repository at this point in the history
  • Loading branch information
hashmap authored Oct 3, 2019
1 parent 7861a40 commit 62d865c
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 54 deletions.
184 changes: 139 additions & 45 deletions core/fuzz/Cargo.lock

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions core/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@ git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
members = ["."]

[[bin]]
name = "transaction_read"
path = "fuzz_targets/transaction_read.rs"
name = "transaction_read_v1"
path = "fuzz_targets/transaction_read_v1.rs"

[[bin]]
name = "transaction_read_v2"
path = "fuzz_targets/transaction_read_v2.rs"

[[bin]]
name = "gen-corpus"
path = "src/main.rs"

[[bin]]
name = "block_read"
path = "fuzz_targets/block_read.rs"
name = "block_read_v1"
path = "fuzz_targets/block_read_v2.rs"

[[bin]]
name = "block_read_v2"
path = "fuzz_targets/block_read_v2.rs"

[[bin]]
name = "compact_block_read_v1"
path = "fuzz_targets/compact_block_read_v1.rs"

[[bin]]
name = "compact_block_read"
path = "fuzz_targets/compact_block_read.rs"
name = "compact_block_read_v2"
path = "fuzz_targets/compact_block_read_v2.rs"
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<Block, ser::Error> = ser::deserialize(&mut d);
let _t: Result<Block, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(1));
});
12 changes: 12 additions & 0 deletions core/fuzz/fuzz_targets/block_read_v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![no_main]
extern crate grin_core;
#[macro_use]
extern crate libfuzzer_sys;

use grin_core::core::Block;
use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<Block, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(2));
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<CompactBlock, ser::Error> = ser::deserialize(&mut d);
let _t: Result<CompactBlock, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(1));
});
12 changes: 12 additions & 0 deletions core/fuzz/fuzz_targets/compact_block_read_v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![no_main]
extern crate grin_core;
#[macro_use]
extern crate libfuzzer_sys;

use grin_core::core::CompactBlock;
use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<CompactBlock, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(2));
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<Transaction, ser::Error> = ser::deserialize(&mut d);
let _t: Result<Transaction, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(1));
});
12 changes: 12 additions & 0 deletions core/fuzz/fuzz_targets/transaction_read_v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![no_main]
extern crate grin_core;
#[macro_use]
extern crate libfuzzer_sys;

use grin_core::core::Transaction;
use grin_core::ser;

fuzz_target!(|data: &[u8]| {
let mut d = data.clone();
let _t: Result<Transaction, ser::Error> = ser::deserialize(&mut d, ser::ProtocolVersion(2));
});

0 comments on commit 62d865c

Please sign in to comment.