Skip to content

Commit 1101a79

Browse files
committed
Merge #792: fuzz: add target for tapscript parsing from script
f96bf24 fuzz: add target for tapscript parsing from script (Bruno Garcia) Pull request description: This PR adds a new fuzz target to parse a miniscript from script hex for Tap. We currently have one target that does it for Segwitv0. ACKs for top commit: apoelstra: ACK f96bf24; successfully ran local tests Tree-SHA512: 97f61c52b5c582a278264a00df0c8cd7b871012f845f1b28dfd6d5fd3fceccef82b13b27bfed2357c67edf6181b53731eb71a244b73dc6599e839aab2ce78ccf
2 parents ee5e1f0 + f96bf24 commit 1101a79

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.github/workflows/cron-daily-fuzz.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ regression_descriptor_parse,
2727
roundtrip_concrete,
2828
roundtrip_descriptor,
2929
roundtrip_miniscript_script,
30+
roundtrip_miniscript_script_tap,
3031
roundtrip_miniscript_str,
3132
roundtrip_semantic,
3233
]

fuzz/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ path = "fuzz_targets/roundtrip_descriptor.rs"
5454
name = "roundtrip_miniscript_script"
5555
path = "fuzz_targets/roundtrip_miniscript_script.rs"
5656

57+
[[bin]]
58+
name = "roundtrip_miniscript_script_tap"
59+
path = "fuzz_targets/roundtrip_miniscript_script_tap.rs"
60+
5761
[[bin]]
5862
name = "roundtrip_miniscript_str"
5963
path = "fuzz_targets/roundtrip_miniscript_str.rs"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(unexpected_cfgs)]
2+
3+
use honggfuzz::fuzz;
4+
use miniscript::bitcoin::blockdata::script;
5+
use miniscript::{Miniscript, Tap};
6+
7+
fn do_test(data: &[u8]) {
8+
// Try round-tripping as a script
9+
let script = script::Script::from_bytes(data);
10+
11+
if let Ok(pt) = Miniscript::<miniscript::bitcoin::key::XOnlyPublicKey, Tap>::parse(script) {
12+
let output = pt.encode();
13+
assert_eq!(pt.script_size(), output.len());
14+
assert_eq!(&output, script);
15+
}
16+
}
17+
18+
fn main() {
19+
loop {
20+
fuzz!(|data| {
21+
do_test(data);
22+
});
23+
}
24+
}

0 commit comments

Comments
 (0)