Skip to content

Commit 1593355

Browse files
committed
elip151: additional invalid test case
For multipath with length mismatch.
1 parent 63b6771 commit 1593355

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/confidential/elip151.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ mod test {
140140
desc: &str,
141141
) -> Result<ConfidentialDescriptor<DescriptorPublicKey>, Error> {
142142
let desc = add_checksum(desc);
143-
let desc = OrdinaryDescriptor::<DescriptorPublicKey>::from_str(&desc).unwrap();
143+
let desc = OrdinaryDescriptor::<DescriptorPublicKey>::from_str(&desc)?;
144144
ConfidentialDescriptor::with_elip151_descriptor_blinding_key(desc)
145145
}
146146

@@ -200,16 +200,21 @@ mod test {
200200
}
201201

202202
_i = 0;
203-
for invalid_desc in [&format!("elwpkh({xpub})"), &format!("elwpkh({pubkey})")] {
203+
let text = "Descriptors without wildcards are not supported in elip151".to_string();
204+
for (invalid_desc, expected_err) in [
205+
(&format!("elwpkh({xpub})"), Error::Unexpected(text.to_string())),
206+
(&format!("elwpkh({pubkey})"), Error::Unexpected(text.to_string())),
207+
(&format!("elwsh(multi(2,{xpub}/<0;1>/*,{xpub}/0/<0;1;2>/*))"), Error::MultipathDescLenMismatch),
208+
] {
204209
let err = confidential_descriptor(invalid_desc).unwrap_err();
205-
let text = "Descriptors without wildcards are not supported in elip151".to_string();
206-
assert_eq!(err, Error::Unexpected(text));
210+
assert_eq!(err, expected_err);
207211
/*
208212
_i = _i + 1;
209213
println!("* Invalid Test vector {}", _i);
210214
println!("** Ordinary descriptor: <code>{}</code>", add_checksum(invalid_desc));
211215
println!("** Invalid confidential descriptor: <code>{}</code>", add_checksum(&format!("ct(elip151,{})", invalid_desc)));
212216
*/
213217
}
218+
214219
}
215220
}

0 commit comments

Comments
 (0)