File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -221,4 +221,34 @@ mod test {
221
221
format!( "Invalid descriptor: Invalid character in checksum: '{}'" , sparkle_heart)
222
222
) ;
223
223
}
224
+
225
+ #[ test]
226
+ fn bip_380_test_vectors_checksum_and_character_set_valid ( ) {
227
+ let tcs = vec ! [
228
+ "raw(deadbeef)#89f8spxm" , // Valid checksum.
229
+ "raw(deadbeef)" , // No checksum.
230
+ ] ;
231
+ for tc in tcs {
232
+ if verify_checksum ( tc) . is_err ( ) {
233
+ panic ! ( "false negative: {}" , tc)
234
+ }
235
+ }
236
+ }
237
+
238
+ #[ test]
239
+ fn bip_380_test_vectors_checksum_and_character_set_invalid ( ) {
240
+ let tcs = vec ! [
241
+ "raw(deadbeef)#" , // Missing checksum.
242
+ "raw(deadbeef)#89f8spxmx" , // Too long checksum.
243
+ "raw(deadbeef)#89f8spx" , // Too short checksum.
244
+ "raw(dedbeef)#89f8spxm" , // Error in payload.
245
+ "raw(deadbeef)##9f8spxm" , // Error in checksum.
246
+ "raw(Ü)#00000000" , // Invalid characters in payload.
247
+ ] ;
248
+ for tc in tcs {
249
+ if verify_checksum ( tc) . is_ok ( ) {
250
+ panic ! ( "false positive: {}" , tc)
251
+ }
252
+ }
253
+ }
224
254
}
You can’t perform that action at this time.
0 commit comments