Skip to content

Commit d7461e4

Browse files
committed
Add zst tests and some other parsing tests
1 parent ddb8e4f commit d7461e4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/key.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,36 @@ mod test {
576576
PublicKey::from_slice(&[0x55; constants::PUBLIC_KEY_SIZE]),
577577
Err(InvalidPublicKey)
578578
);
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+
);
579609
}
580610

581611
#[test]

0 commit comments

Comments
 (0)