Skip to content

Commit

Permalink
elip151: additional invalid test case
Browse files Browse the repository at this point in the history
For multipath with length mismatch.
  • Loading branch information
LeoComandini committed May 13, 2024
1 parent 63b6771 commit 1593355
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/confidential/elip151.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod test {
desc: &str,
) -> Result<ConfidentialDescriptor<DescriptorPublicKey>, Error> {
let desc = add_checksum(desc);
let desc = OrdinaryDescriptor::<DescriptorPublicKey>::from_str(&desc).unwrap();
let desc = OrdinaryDescriptor::<DescriptorPublicKey>::from_str(&desc)?;
ConfidentialDescriptor::with_elip151_descriptor_blinding_key(desc)
}

Expand Down Expand Up @@ -200,16 +200,21 @@ mod test {
}

_i = 0;
for invalid_desc in [&format!("elwpkh({xpub})"), &format!("elwpkh({pubkey})")] {
let text = "Descriptors without wildcards are not supported in elip151".to_string();
for (invalid_desc, expected_err) in [
(&format!("elwpkh({xpub})"), Error::Unexpected(text.to_string())),
(&format!("elwpkh({pubkey})"), Error::Unexpected(text.to_string())),
(&format!("elwsh(multi(2,{xpub}/<0;1>/*,{xpub}/0/<0;1;2>/*))"), Error::MultipathDescLenMismatch),
] {
let err = confidential_descriptor(invalid_desc).unwrap_err();
let text = "Descriptors without wildcards are not supported in elip151".to_string();
assert_eq!(err, Error::Unexpected(text));
assert_eq!(err, expected_err);
/*
_i = _i + 1;
println!("* Invalid Test vector {}", _i);
println!("** Ordinary descriptor: <code>{}</code>", add_checksum(invalid_desc));
println!("** Invalid confidential descriptor: <code>{}</code>", add_checksum(&format!("ct(elip151,{})", invalid_desc)));
*/
}

}
}

0 comments on commit 1593355

Please sign in to comment.