-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
descriptor: add fuzz test comparing to published rust-miniscript 12
This bumps the local Cargo.toml version to 13, which will be the next release (since we've made many breaking changes), and in the fuzz test adds an explicit dependency on miniscript 12 from crates.io, as `old_miniscript`. Adds a single fuzztest which attempt to parse descriptors with both master and 12, to make sure they're the same.
- Loading branch information
Showing
7 changed files
with
77 additions
and
5 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "miniscript" | ||
version = "12.2.0" | ||
version = "13.0.0" | ||
authors = ["Andrew Poelstra <[email protected]>, Sanket Kanjalkar <[email protected]>"] | ||
license = "CC0-1.0" | ||
homepage = "https://github.com/rust-bitcoin/rust-miniscript/" | ||
|
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,43 @@ | ||
use core::str::FromStr; | ||
|
||
use honggfuzz::fuzz; | ||
use miniscript::{Descriptor, DescriptorPublicKey}; | ||
use old_miniscript::{Descriptor as OldDescriptor, DescriptorPublicKey as OldDescriptorPublicKey}; | ||
|
||
type Desc = Descriptor<DescriptorPublicKey>; | ||
type OldDesc = OldDescriptor<OldDescriptorPublicKey>; | ||
|
||
fn do_test(data: &[u8]) { | ||
let data_str = String::from_utf8_lossy(data); | ||
match (Desc::from_str(&data_str), OldDesc::from_str(&data_str)) { | ||
(Err(_), Err(_)) => {} | ||
(Ok(x), Err(e)) => panic!("new logic parses {} as {:?}, old fails with {}", data_str, x, e), | ||
(Err(e), Ok(x)) => panic!("old logic parses {} as {:?}, new fails with {}", data_str, x, e), | ||
(Ok(new), Ok(old)) => { | ||
assert_eq!( | ||
old.to_string(), | ||
new.to_string(), | ||
"input {} (left is old, right is new)", | ||
data_str | ||
) | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
loop { | ||
fuzz!(|data| { | ||
do_test(data); | ||
}); | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn duplicate_crash() { | ||
crate::do_test( | ||
b"tr(02dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd,{1,unun:0})", | ||
) | ||
} | ||
} |
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