Add unit test for tapscript function
Add a unit test that verifies we correctly remove the annex when getting the tapscript from the witness stack. Unit test written by Casey, pulled out of #3599. Co-developed-by: Casey Rodarmor <casey@rodarmor.com>
This commit is contained in:
parent
195615c14d
commit
1ed3fc9270
|
@ -306,6 +306,26 @@ mod test {
|
||||||
assert_eq!(witness_annex.tapscript(), Some(Script::from_bytes(&tapscript[..])));
|
assert_eq!(witness_annex.tapscript(), Some(Script::from_bytes(&tapscript[..])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_tapscript_from_keypath() {
|
||||||
|
let signature = hex!("deadbeef");
|
||||||
|
// annex starting with 0x50 causes the branching logic.
|
||||||
|
let annex = hex!("50");
|
||||||
|
|
||||||
|
let witness_vec = vec![signature.clone()];
|
||||||
|
let witness_vec_annex = vec![signature.clone(), annex];
|
||||||
|
|
||||||
|
let witness_serialized: Vec<u8> = serialize(&witness_vec);
|
||||||
|
let witness_serialized_annex: Vec<u8> = serialize(&witness_vec_annex);
|
||||||
|
|
||||||
|
let witness = deserialize::<Witness>(&witness_serialized[..]).unwrap();
|
||||||
|
let witness_annex = deserialize::<Witness>(&witness_serialized_annex[..]).unwrap();
|
||||||
|
|
||||||
|
// With or without annex, no tapscript should be returned.
|
||||||
|
assert_eq!(witness.tapscript(), None);
|
||||||
|
assert_eq!(witness_annex.tapscript(), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_control_block() {
|
fn test_get_control_block() {
|
||||||
let tapscript = hex!("deadbeef");
|
let tapscript = hex!("deadbeef");
|
||||||
|
|
Loading…
Reference in New Issue