Skip to content

Commit eb6a9d2

Browse files
committed
descriptor: add unit tests for constructing multipath keys
1 parent c9dcbd5 commit eb6a9d2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/descriptor/key.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ mod test {
13851385
use super::{
13861386
DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey, MiniscriptKey, Wildcard,
13871387
};
1388-
use crate::prelude::*;
1388+
use crate::{prelude::*, DefiniteDescriptorKey};
13891389

13901390
#[test]
13911391
fn parse_descriptor_key_errors() {
@@ -1768,4 +1768,24 @@ mod test {
17681768
let public_key = DescriptorPublicKey::from_str(desc).unwrap();
17691769
assert_tokens(&public_key, &[Token::String(desc)]);
17701770
}
1771+
1772+
#[test]
1773+
fn definite_keys() {
1774+
type DefDesc = crate::Descriptor<DescriptorPublicKey>;
1775+
// basic xpub
1776+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1777+
.parse::<DescriptorPublicKey>()
1778+
.unwrap();
1779+
assert!(DefiniteDescriptorKey::new(desc).is_some());
1780+
// xpub with wildcard
1781+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1782+
.parse::<DescriptorPublicKey>()
1783+
.unwrap();
1784+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1785+
// multipath xpub
1786+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1787+
.parse::<DescriptorPublicKey>()
1788+
.unwrap();
1789+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1790+
}
17711791
}

0 commit comments

Comments
 (0)