Skip to content

Commit f652949

Browse files
committed
descriptor: add unit tests for constructing multipath keys
1 parent c07272a commit f652949

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/descriptor/key.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ mod test {
11501150
DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey,
11511151
MiniscriptKey, Wildcard,
11521152
};
1153-
use crate::prelude::*;
1153+
use crate::{prelude::*, DefiniteDescriptorKey};
11541154

11551155
#[test]
11561156
fn parse_descriptor_key_errors() {
@@ -1498,4 +1498,23 @@ mod test {
14981498
let public_key = DescriptorPublicKey::from_str(desc).unwrap();
14991499
assert_tokens(&public_key, &[Token::String(desc)]);
15001500
}
1501+
1502+
#[test]
1503+
fn definite_keys() {
1504+
// basic xpub
1505+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1506+
.parse::<DescriptorPublicKey>()
1507+
.unwrap();
1508+
assert!(DefiniteDescriptorKey::new(desc).is_some());
1509+
// xpub with wildcard
1510+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1511+
.parse::<DescriptorPublicKey>()
1512+
.unwrap();
1513+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1514+
// multipath xpub
1515+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1516+
.parse::<DescriptorPublicKey>()
1517+
.unwrap();
1518+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1519+
}
15011520
}

0 commit comments

Comments
 (0)