mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-08 22:28:12 -05:00
fuzz: Serialize attempt
This commit is contained in:
5
fuzz/.gitignore
vendored
Normal file
5
fuzz/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
target
|
||||
corpus
|
||||
artifacts
|
||||
coverage
|
||||
Cargo.lock
|
||||
31
fuzz/Cargo.toml
Normal file
31
fuzz/Cargo.toml
Normal 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
|
||||
13
fuzz/fuzz_targets/serial.rs
Normal file
13
fuzz/fuzz_targets/serial.rs
Normal 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);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user