Skip to content

Commit

Permalink
Merge pull request #131 from darosior/descriptor_publickey
Browse files Browse the repository at this point in the history
DescriptorPublicKey, second pass
  • Loading branch information
apoelstra authored Oct 1, 2020
2 parents 7236b57 + 28158a3 commit e0fc688
Show file tree
Hide file tree
Showing 3 changed files with 489 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ path = "fuzz_targets/roundtrip_semantic.rs"

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

[[bin]]
name = "parse_descriptor"
path = "fuzz_targets/parse_descriptor.rs"
33 changes: 33 additions & 0 deletions fuzz/fuzz_targets/parse_descriptor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
extern crate miniscript;

use miniscript::descriptor::DescriptorPublicKey;
use std::str::FromStr;

fn do_test(data: &[u8]) {
let data_str = String::from_utf8_lossy(data);
if let Ok(dpk) = DescriptorPublicKey::from_str(&data_str) {
let output = dpk.to_string();
assert_eq!(data_str.to_lowercase(), output.to_lowercase());
}
}

#[cfg(feature = "afl")]
extern crate afl;
#[cfg(feature = "afl")]
fn main() {
afl::read_stdio_bytes(|data| {
do_test(&data);
});
}

#[cfg(feature = "honggfuzz")]
#[macro_use]
extern crate honggfuzz;
#[cfg(feature = "honggfuzz")]
fn main() {
loop {
fuzz!(|data| {
do_test(data);
});
}
}
Loading

0 comments on commit e0fc688

Please sign in to comment.