From 756b110854ca81ad37ea26f786ff8623db3a7a2b Mon Sep 17 00:00:00 2001 From: Age Manning Date: Tue, 17 Mar 2020 11:07:52 +1100 Subject: [PATCH] Fix master failing test (#915) * Use a valid secret key in ssz test * Correct test_random secret key tests --- .../types/src/test_utils/test_random/secret_key.rs | 14 ++------------ eth2/utils/bls/src/secret_key.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/eth2/types/src/test_utils/test_random/secret_key.rs b/eth2/types/src/test_utils/test_random/secret_key.rs index 7953b7c53..33fbcec56 100644 --- a/eth2/types/src/test_utils/test_random/secret_key.rs +++ b/eth2/types/src/test_utils/test_random/secret_key.rs @@ -2,17 +2,7 @@ use super::*; use bls::SecretKey; impl TestRandom for SecretKey { - fn random_for_test(rng: &mut impl RngCore) -> Self { - let mut key_bytes = vec![0; 48]; - rng.fill_bytes(&mut key_bytes); - /* - * An `unreachable!` is used here as there's no reason why you cannot construct a key from a - * fixed-length byte slice. Also, this should only be used during testing so a panic is - * acceptable. - */ - match SecretKey::from_bytes(&key_bytes) { - Ok(key) => key, - Err(_) => unreachable!(), - } + fn random_for_test(_rng: &mut impl RngCore) -> Self { + SecretKey::random() } } diff --git a/eth2/utils/bls/src/secret_key.rs b/eth2/utils/bls/src/secret_key.rs index 65f02edc9..a930e65cc 100644 --- a/eth2/utils/bls/src/secret_key.rs +++ b/eth2/utils/bls/src/secret_key.rs @@ -79,8 +79,12 @@ mod tests { #[test] pub fn test_ssz_round_trip() { - let original = - SecretKey::from_bytes(b"jzjxxgjajfjrmgodszzsgqccmhnyvetcuxobhtynojtpdtbj").unwrap(); + let byte_key = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 211, 210, 129, 231, 69, 162, 234, + 16, 15, 244, 214, 126, 201, 0, 85, 28, 239, 82, 121, 208, 190, 223, 6, 169, 202, 86, + 236, 197, 218, 3, 69, + ]; + let original = SecretKey::from_bytes(&byte_key).unwrap(); let bytes = ssz_encode(&original); let decoded = SecretKey::from_ssz_bytes(&bytes).unwrap();