forked from rust-bitcoin/rust-miniscript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge rust-bitcoin#792: fuzz: add target for tapscript parsing from s…
…cript 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
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![allow(unexpected_cfgs)] | ||
|
||
use honggfuzz::fuzz; | ||
use miniscript::bitcoin::blockdata::script; | ||
use miniscript::{Miniscript, Tap}; | ||
|
||
fn do_test(data: &[u8]) { | ||
// Try round-tripping as a script | ||
let script = script::Script::from_bytes(data); | ||
|
||
if let Ok(pt) = Miniscript::<miniscript::bitcoin::key::XOnlyPublicKey, Tap>::parse(script) { | ||
let output = pt.encode(); | ||
assert_eq!(pt.script_size(), output.len()); | ||
assert_eq!(&output, script); | ||
} | ||
} | ||
|
||
fn main() { | ||
loop { | ||
fuzz!(|data| { | ||
do_test(data); | ||
}); | ||
} | ||
} |