Skip to content

Commit

Permalink
test: Fuzz reconstruction of values
Browse files Browse the repository at this point in the history
This fuzz target is 10x slower than our other targets. I suspect that
Simfony values such as [u8; 256] are cheap for the fuzzer to generate,
but they correspond to deeply nested trees of products in the Simplicity
world, which slows down the target. Maybe this is just how it is; maybe
we can be smarter about this. A saving grace is that we almost never
convert Simplicity values to Simfony values. The only use case right now
is to display debug information from the Simplicity Bit Machine.
  • Loading branch information
uncomputable committed Sep 12, 2024
1 parent 2671dc8 commit 88d15d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ path = "fuzz_targets/display_parse_tree.rs"
test = false
doc = false
bench = false

[[bin]]
name = "reconstruct_value"
path = "fuzz_targets/reconstruct_value.rs"
test = false
doc = false
bench = false
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/reconstruct_value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]

use libfuzzer_sys::fuzz_target;

use simfony::value::{Value, StructuralValue};

fuzz_target!(|value: Value| {
let structural_value = StructuralValue::from(&value);
let reconstructed_value = Value::reconstruct(&structural_value, value.ty()).unwrap();
assert_eq!(reconstructed_value, value);
});

0 comments on commit 88d15d3

Please sign in to comment.