Skip to content

Commit 1af2b19

Browse files
committed
fuzz: use FuzzPk in regression_descriptor_parse.rs
This makes the fuzztest significantly faster. If we want to search regressions in the parsing of DescriptorPublicKey then we should have a fuzztest specifically for that.
1 parent e072944 commit 1af2b19

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

fuzz/fuzz_targets/regression_descriptor_parse.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use core::str::FromStr;
22

33
use honggfuzz::fuzz;
4-
use miniscript::{Descriptor, DescriptorPublicKey};
5-
use old_miniscript::{Descriptor as OldDescriptor, DescriptorPublicKey as OldDescriptorPublicKey};
4+
use miniscript::Descriptor;
5+
use old_miniscript::Descriptor as OldDescriptor;
66

7-
type Desc = Descriptor<DescriptorPublicKey>;
8-
type OldDesc = OldDescriptor<OldDescriptorPublicKey>;
7+
type Desc = Descriptor<descriptor_fuzz::FuzzPk>;
8+
type OldDesc = OldDescriptor<descriptor_fuzz::FuzzPk>;
99

1010
fn do_test(data: &[u8]) {
1111
let data_str = String::from_utf8_lossy(data);
@@ -35,9 +35,5 @@ fn main() {
3535
#[cfg(test)]
3636
mod tests {
3737
#[test]
38-
fn duplicate_crash() {
39-
crate::do_test(
40-
b"tr(02dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd,{1,unun:0})",
41-
)
42-
}
38+
fn duplicate_crash() { crate::do_test(b"tr(d,{0,{0,0}})") }
4339
}

fuzz/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ impl MiniscriptKey for FuzzPk {
4242
type Hash256 = u8;
4343
}
4444

45+
impl old_miniscript::MiniscriptKey for FuzzPk {
46+
type Sha256 = u8;
47+
type Ripemd160 = u8;
48+
type Hash160 = u8;
49+
type Hash256 = u8;
50+
}
51+
4552
impl ToPublicKey for FuzzPk {
4653
fn to_public_key(&self) -> PublicKey {
4754
let secp_pk = secp256k1::PublicKey::from_slice(&[

0 commit comments

Comments
 (0)