fuzz: Serialize attempt

This commit is contained in:
parazyd
2023-08-23 22:21:42 +02:00
parent 3d867832ac
commit 00e4456787
3 changed files with 49 additions and 0 deletions

5
fuzz/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
target
corpus
artifacts
coverage
Cargo.lock

31
fuzz/Cargo.toml Normal file
View File

@@ -0,0 +1,31 @@
[package]
name = "darkfi-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
[dependencies.darkfi]
path = ".."
[dependencies.darkfi-serial]
path = "../src/serial"
features = ["derive", "semver", "collections", "crypto", "hash"]
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[profile.release]
debug = 1
[[bin]]
name = "serial"
path = "fuzz_targets/serial.rs"
test = false
doc = false

View File

@@ -0,0 +1,13 @@
#![no_main]
extern crate darkfi_serial;
use darkfi_serial::{deserialize, serialize};
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let ser = serialize(&s);
let des: String = deserialize(&ser).unwrap();
assert_eq!(s, des);
}
});