Skip to content

Commit

Permalink
Merge #787: fuzz: add target for Descriptor::parse_descriptor
Browse files Browse the repository at this point in the history
eb1e9f6 fuzz: add target for `Descriptor::parse_descriptor` (Bruno Garcia)

Pull request description:

ACKs for top commit:
  sanket1729:
    ACK eb1e9f6
  apoelstra:
    ACK eb1e9f6; successfully ran local tests; thanks!

Tree-SHA512: bec4da195b0f7370b81a62f1f2c92d84f862ca1ebfaee3f8fcc22d858fccdd15390f9839beaef7a6e6dac8b17484e534cce4581fb7b11f82df360e88c75ce0c3
  • Loading branch information
apoelstra committed Dec 24, 2024
2 parents f3704d1 + eb1e9f6 commit a17b34c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ path = "fuzz_targets/compile_taproot.rs"
name = "parse_descriptor"
path = "fuzz_targets/parse_descriptor.rs"

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

[[bin]]
name = "parse_descriptor_secret"
path = "fuzz_targets/parse_descriptor_secret.rs"
Expand Down
23 changes: 23 additions & 0 deletions fuzz/fuzz_targets/parse_descriptor_priv.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![allow(unexpected_cfgs)]

use honggfuzz::fuzz;
use miniscript::bitcoin::secp256k1;
use miniscript::Descriptor;

fn do_test(data: &[u8]) {
let data_str = String::from_utf8_lossy(data);
let secp = &secp256k1::Secp256k1::signing_only();

if let Ok((desc, _)) = Descriptor::parse_descriptor(secp, &data_str) {
let _output = desc.to_string();
let _sanity_check = desc.sanity_check();
}
}

fn main() {
loop {
fuzz!(|data| {
do_test(data);
});
}
}

0 comments on commit a17b34c

Please sign in to comment.