Skip to content

Commit 700feab

Browse files
committed
fuzz: update taptree regression test to also check control blocks
This is a bit of a pain because the old lookup-by-script behavior doesn't map cleanly onto the new iterate-through-everything behavior. But this test is definitely useful (the unit tests in the previous commit came from it.)
1 parent 820f9b8 commit 700feab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fuzz/fuzz_targets/regression_taptree.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::{HashMap, HashSet};
2+
13
use descriptor_fuzz::FuzzPk;
24
use honggfuzz::fuzz;
35
use miniscript::descriptor::Tr;
@@ -27,6 +29,22 @@ fn do_test(data: &[u8]) {
2729
new_si.output_key(),
2830
"merkle root mismatch (left is old, new is right)",
2931
);
32+
33+
// Map every leaf script to a set of all the control blocks
34+
let mut new_cbs = HashMap::new();
35+
for leaf in new_si.leaves() {
36+
new_cbs
37+
.entry(leaf.script())
38+
.or_insert(HashSet::new())
39+
.insert(leaf.control_block().clone());
40+
}
41+
// ...the old code will only ever yield one of them and it's not easy to predict which one
42+
for leaf in new_si.leaves() {
43+
let old_cb = old_si
44+
.control_block(&(leaf.script().into(), leaf.leaf_version()))
45+
.unwrap();
46+
assert!(new_cbs[leaf.script()].contains(&old_cb));
47+
}
3048
}
3149
}
3250
}

0 commit comments

Comments
 (0)