From d7461e4cdc46928fbe88a56471eef3c4cd4d469b Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Wed, 21 Aug 2019 17:58:55 -0400 Subject: [PATCH] Add zst tests and some other parsing tests --- src/key.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/key.rs b/src/key.rs index 2e64df0..38f3cdf 100644 --- a/src/key.rs +++ b/src/key.rs @@ -576,6 +576,36 @@ mod test { PublicKey::from_slice(&[0x55; constants::PUBLIC_KEY_SIZE]), Err(InvalidPublicKey) ); + assert_eq!( + PublicKey::from_slice(&[]), + Err(InvalidPublicKey) + ); + } + + #[test] + fn test_seckey_from_bad_slice() { + // Bad sizes + assert_eq!( + SecretKey::from_slice(&[0; constants::SECRET_KEY_SIZE - 1]), + Err(InvalidSecretKey) + ); + assert_eq!( + SecretKey::from_slice(&[0; constants::SECRET_KEY_SIZE + 1]), + Err(InvalidSecretKey) + ); + // Bad parse + assert_eq!( + SecretKey::from_slice(&[0xff; constants::SECRET_KEY_SIZE]), + Err(InvalidSecretKey) + ); + assert_eq!( + SecretKey::from_slice(&[0x00; constants::SECRET_KEY_SIZE]), + Err(InvalidSecretKey) + ); + assert_eq!( + SecretKey::from_slice(&[]), + Err(InvalidSecretKey) + ); } #[test]