Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix master failing test #915

Merged
merged 2 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions eth2/types/src/test_utils/test_random/secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
8 changes: 6 additions & 2 deletions eth2/utils/bls/src/secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down