File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -576,6 +576,36 @@ mod test {
576
576
PublicKey :: from_slice( & [ 0x55 ; constants:: PUBLIC_KEY_SIZE ] ) ,
577
577
Err ( InvalidPublicKey )
578
578
) ;
579
+ assert_eq ! (
580
+ PublicKey :: from_slice( & [ ] ) ,
581
+ Err ( InvalidPublicKey )
582
+ ) ;
583
+ }
584
+
585
+ #[ test]
586
+ fn test_seckey_from_bad_slice ( ) {
587
+ // Bad sizes
588
+ assert_eq ! (
589
+ SecretKey :: from_slice( & [ 0 ; constants:: SECRET_KEY_SIZE - 1 ] ) ,
590
+ Err ( InvalidSecretKey )
591
+ ) ;
592
+ assert_eq ! (
593
+ SecretKey :: from_slice( & [ 0 ; constants:: SECRET_KEY_SIZE + 1 ] ) ,
594
+ Err ( InvalidSecretKey )
595
+ ) ;
596
+ // Bad parse
597
+ assert_eq ! (
598
+ SecretKey :: from_slice( & [ 0xff ; constants:: SECRET_KEY_SIZE ] ) ,
599
+ Err ( InvalidSecretKey )
600
+ ) ;
601
+ assert_eq ! (
602
+ SecretKey :: from_slice( & [ 0x00 ; constants:: SECRET_KEY_SIZE ] ) ,
603
+ Err ( InvalidSecretKey )
604
+ ) ;
605
+ assert_eq ! (
606
+ SecretKey :: from_slice( & [ ] ) ,
607
+ Err ( InvalidSecretKey )
608
+ ) ;
579
609
}
580
610
581
611
#[ test]
You can’t perform that action at this time.
0 commit comments