File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1919 # over that limit with fuzzing because of the hour run time.
2020 fuzz_target : [
2121compile_descriptor,
22+ compile_taproot,
2223parse_descriptor,
2324parse_descriptor_secret,
2425roundtrip_concrete,
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ regex = "1.0"
1919name = " compile_descriptor"
2020path = " fuzz_targets/compile_descriptor.rs"
2121
22+ [[bin ]]
23+ name = " compile_taproot"
24+ path = " fuzz_targets/compile_taproot.rs"
25+
2226[[bin ]]
2327name = " parse_descriptor"
2428path = " fuzz_targets/parse_descriptor.rs"
Original file line number Diff line number Diff line change 1+ #![ allow( unexpected_cfgs) ]
2+
3+ use std:: str:: FromStr ;
4+
5+ use honggfuzz:: fuzz;
6+ use miniscript:: { policy, Miniscript , Tap } ;
7+ use policy:: Liftable ;
8+
9+ type Script = Miniscript < String , Tap > ;
10+ type Policy = policy:: Concrete < String > ;
11+
12+ fn do_test ( data : & [ u8 ] ) {
13+ let data_str = String :: from_utf8_lossy ( data) ;
14+ if let Ok ( pol) = Policy :: from_str ( & data_str) {
15+ // Compile
16+ if let Ok ( desc) = pol. compile :: < Tap > ( ) {
17+ // Lift
18+ assert_eq ! ( desc. lift( ) . unwrap( ) . sorted( ) , pol. lift( ) . unwrap( ) . sorted( ) ) ;
19+ // Try to roundtrip the output of the compiler
20+ let output = desc. to_string ( ) ;
21+ if let Ok ( desc) = Script :: from_str ( & output) {
22+ let rtt = desc. to_string ( ) ;
23+ assert_eq ! ( output. to_lowercase( ) , rtt. to_lowercase( ) ) ;
24+ } else {
25+ panic ! ( "compiler output something unparseable: {}" , output)
26+ }
27+ }
28+ }
29+ }
30+
31+ fn main ( ) {
32+ loop {
33+ fuzz ! ( |data| {
34+ do_test( data) ;
35+ } ) ;
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ publish = false
2222cargo-fuzz = true
2323
2424[dependencies]
25- honggfuzz = { version = "0.5.55 ", default-features = false }
25+ honggfuzz = { version = "0.5.56 ", default-features = false }
2626miniscript = { path = "..", features = [ "compiler" ] }
2727
2828regex = "1.0"
You can’t perform that action at this time.
0 commit comments