From 159335558c7b37712b49e2019f7975f64aef0b7a Mon Sep 17 00:00:00 2001 From: Leonardo Comandini Date: Mon, 13 May 2024 11:34:49 +0200 Subject: [PATCH] elip151: additional invalid test case For multipath with length mismatch. --- src/confidential/elip151.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/confidential/elip151.rs b/src/confidential/elip151.rs index f11dfc15..227f068c 100644 --- a/src/confidential/elip151.rs +++ b/src/confidential/elip151.rs @@ -140,7 +140,7 @@ mod test { desc: &str, ) -> Result, Error> { let desc = add_checksum(desc); - let desc = OrdinaryDescriptor::::from_str(&desc).unwrap(); + let desc = OrdinaryDescriptor::::from_str(&desc)?; ConfidentialDescriptor::with_elip151_descriptor_blinding_key(desc) } @@ -200,10 +200,14 @@ 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); @@ -211,5 +215,6 @@ mod test { println!("** Invalid confidential descriptor: {}", add_checksum(&format!("ct(elip151,{})", invalid_desc))); */ } + } }