Skip to content

Commit 29808ae

Browse files
committed
descriptor: add unit tests for constructing multipath keys
1 parent b41daad commit 29808ae

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
@@ -1190,7 +1190,7 @@ mod test {
11901190
DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey,
11911191
MiniscriptKey, Wildcard,
11921192
};
1193-
use crate::prelude::*;
1193+
use crate::{prelude::*, DefiniteDescriptorKey};
11941194

11951195
#[test]
11961196
fn parse_descriptor_key_errors() {
@@ -1571,4 +1571,23 @@ mod test {
15711571
let public_key = DescriptorPublicKey::from_str(desc).unwrap();
15721572
assert_tokens(&public_key, &[Token::String(desc)]);
15731573
}
1574+
1575+
#[test]
1576+
fn definite_keys() {
1577+
// basic xpub
1578+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1579+
.parse::<DescriptorPublicKey>()
1580+
.unwrap();
1581+
assert!(DefiniteDescriptorKey::new(desc).is_some());
1582+
// xpub with wildcard
1583+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1584+
.parse::<DescriptorPublicKey>()
1585+
.unwrap();
1586+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1587+
// multipath xpub
1588+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1589+
.parse::<DescriptorPublicKey>()
1590+
.unwrap();
1591+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1592+
}
15741593
}

0 commit comments

Comments
 (0)