Skip to content

Commit bb9a76c

Browse files
committed
descriptor: add lifting unit test
1 parent d1dadc6 commit bb9a76c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/descriptor/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,24 @@ pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
21002100
.unwrap_err();
21012101
}
21022102

2103+
#[test]
2104+
fn tr_lift() {
2105+
use crate::policy::Liftable as _;
2106+
2107+
// Taproot structure is erased but key order preserved..
2108+
let desc = Descriptor::<String>::from_str("tr(ROOT,{pk(A1),{pk(B1),pk(B2)}})").unwrap();
2109+
let lift = desc.lift().unwrap();
2110+
assert_eq!(lift.to_string(), "or(pk(ROOT),or(pk(A1),pk(B1),pk(B2)))",);
2111+
let desc = Descriptor::<String>::from_str("tr(ROOT,{{pk(A1),pk(B1)},pk(B2)})").unwrap();
2112+
let lift = desc.lift().unwrap();
2113+
assert_eq!(lift.to_string(), "or(pk(ROOT),or(pk(A1),pk(B1),pk(B2)))",);
2114+
2115+
// And normalization happens
2116+
let desc = Descriptor::<String>::from_str("tr(ROOT,{0,{0,0}})").unwrap();
2117+
let lift = desc.lift().unwrap();
2118+
assert_eq!(lift.to_string(), "or(pk(ROOT),UNSATISFIABLE)",);
2119+
}
2120+
21032121
#[test]
21042122
fn test_context_pks() {
21052123
let comp_key = bitcoin::PublicKey::from_str(

0 commit comments

Comments
 (0)