forked from ProvableHQ/snarkOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add a cargo-fuzz-powered fuzz test
Signed-off-by: ljedrz <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "snarkos-fuzz" | ||
version = "0.0.0" | ||
authors = ["Automatically generated"] | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
bytes = "1" | ||
libfuzzer-sys = "0.4" | ||
tokio-util = { version = "0.7", features = [ "codec" ] } | ||
|
||
[dependencies.snarkos-environment] | ||
path = "../environment" | ||
features = [ "network" ] | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "fuzz_target_1" | ||
path = "fuzz_targets/fuzz_target_1.rs" | ||
test = false | ||
doc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
use bytes::BytesMut; | ||
use snarkos_environment::{network::MessageCodec, Client, CurrentNetwork}; | ||
use tokio_util::codec::Decoder; | ||
|
||
fuzz_target!(|messages: Vec<&[u8]>| { | ||
let mut codec = MessageCodec::<CurrentNetwork, Client<CurrentNetwork>>::default(); | ||
|
||
for message in messages { | ||
let mut bytes = BytesMut::from(message); | ||
let _ = codec.decode(&mut bytes); | ||
} | ||
}); |