Test with m prefix

We have a single test case that tests for the m prefix while all the
others do not.

Move one test case into the loop and then test on each iteration the
path with m prefix added.
This commit is contained in:
Tobin C. Harding 2025-06-03 11:55:14 +01:00
parent c5073f4c51
commit 0c9dd31f53
No known key found for this signature in database
GPG Key ID: 0AEF0A899E41F7DD
1 changed files with 12 additions and 11 deletions

View File

@ -1151,20 +1151,21 @@ mod tests {
ChildNumber::from_hardened_idx(2).unwrap(),
ChildNumber::from_normal_idx(2).unwrap(),
]),
];
for (path, expected) in valid_paths {
assert_eq!(path.parse::<DerivationPath>().unwrap(), expected.into());
}
let want = DerivationPath::from(vec![
("0'/1/2'/2/1000000000", vec![
ChildNumber::ZERO_HARDENED,
ChildNumber::ONE_NORMAL,
ChildNumber::from_hardened_idx(2).unwrap(),
ChildNumber::from_normal_idx(2).unwrap(),
ChildNumber::from_normal_idx(1000000000).unwrap(),
]);
assert_eq!("0'/1/2'/2/1000000000".parse::<DerivationPath>().unwrap(), want);
assert_eq!("m/0'/1/2'/2/1000000000".parse::<DerivationPath>().unwrap(), want);
]),
];
for (path, expected) in valid_paths {
// Access the inner private field so we don't have to clone expected.
assert_eq!(path.parse::<DerivationPath>().unwrap().0, expected);
// Test with the leading `m` for good measure.
let prefixed = format!("m/{}", path);
assert_eq!(prefixed.parse::<DerivationPath>().unwrap().0, expected);
}
let s = "0'/50/3'/5/545456";
assert_eq!(s.parse::<DerivationPath>(), s.into_derivation_path());