Refactor invalid derivation path tests
Refactor the tests to have the invalid paths in a list, or string.
This commit is contained in:
parent
015fb1be3b
commit
ed36a980f8
|
@ -1099,28 +1099,25 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_derivation_path_invalid_format() {
|
fn parse_derivation_path_invalid_format() {
|
||||||
assert!(matches!(
|
let invalid_paths = [
|
||||||
"n/0'/0".parse::<DerivationPath>(),
|
"n/0'/0",
|
||||||
Err(ParseChildNumberError::ParseInt(..)),
|
"4/m/5",
|
||||||
));
|
"//3/0'",
|
||||||
assert!(matches!(
|
"0h/0x",
|
||||||
"4/m/5".parse::<DerivationPath>(),
|
];
|
||||||
Err(ParseChildNumberError::ParseInt(..)),
|
for path in &invalid_paths {
|
||||||
));
|
assert!(matches!(
|
||||||
assert!(matches!(
|
path.parse::<DerivationPath>(),
|
||||||
"//3/0'".parse::<DerivationPath>(),
|
Err(ParseChildNumberError::ParseInt(..)),
|
||||||
Err(ParseChildNumberError::ParseInt(..)),
|
));
|
||||||
));
|
}
|
||||||
assert!(matches!(
|
|
||||||
"0h/0x".parse::<DerivationPath>(),
|
|
||||||
Err(ParseChildNumberError::ParseInt(..)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_derivation_path_out_of_range() {
|
fn parse_derivation_path_out_of_range() {
|
||||||
|
let invalid_path = "2147483648";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"2147483648".parse::<DerivationPath>(),
|
invalid_path.parse::<DerivationPath>(),
|
||||||
Err(ParseChildNumberError::IndexOutOfRange(IndexOutOfRangeError { index: 2147483648 })),
|
Err(ParseChildNumberError::IndexOutOfRange(IndexOutOfRangeError { index: 2147483648 })),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue