Add fuzzer for Address::from_script

This commit is contained in:
Steven Roose 2019-08-15 21:52:10 +01:00
parent 09a65023a2
commit 3c390ceb93
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,7 @@
extern crate bitcoin;
use bitcoin::util::address::Address;
use bitcoin::network::constants::Network;
use bitcoin::blockdata::script;
use bitcoin::consensus::encode;
@ -32,6 +34,11 @@ fn do_test(data: &[u8]) {
}
assert_eq!(b.into_script(), script);
assert_eq!(data, &encode::serialize(&script)[..]);
// Check if valid address and if that address roundtrips.
if let Some(addr) = Address::from_script(&script, Network::Bitcoin) {
assert_eq!(addr.script_pubkey(), script);
}
}
}