diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index ec1008d3c..ba9c5cd4d 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -8,7 +8,7 @@ use log::{debug, error, trace}; use pubkey_cache::PubkeyCache; use rand::RngCore; use serde_derive::{Deserialize, Serialize}; -use ssz::{hash, Decodable, SignedRoot, TreeHash}; +use ssz::{hash, SignedRoot}; use ssz_derive::{Decode, Encode, TreeHash}; use std::collections::HashMap; use swap_or_not_shuffle::shuffle_list; @@ -128,16 +128,19 @@ pub struct BeaconState { #[ssz(skip_serializing)] #[ssz(skip_deserializing)] #[tree_hash(skip_hashing)] + #[test_random(default)] pub cache_index_offset: usize, #[serde(default)] #[ssz(skip_serializing)] #[ssz(skip_deserializing)] #[tree_hash(skip_hashing)] + #[test_random(default)] pub caches: [EpochCache; CACHED_EPOCHS], #[serde(default)] #[ssz(skip_serializing)] #[ssz(skip_deserializing)] #[tree_hash(skip_hashing)] + #[test_random(default)] pub pubkey_cache: PubkeyCache, } diff --git a/eth2/types/src/beacon_state/epoch_cache.rs b/eth2/types/src/beacon_state/epoch_cache.rs index 3e580eee1..ddcca0a9a 100644 --- a/eth2/types/src/beacon_state/epoch_cache.rs +++ b/eth2/types/src/beacon_state/epoch_cache.rs @@ -1,7 +1,5 @@ use super::{AttestationDuty, BeaconState, CrosslinkCommittees, Error}; -use crate::test_utils::TestRandom; use crate::{ChainSpec, Epoch}; -use rand::RngCore; use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)] @@ -69,14 +67,3 @@ impl EpochCache { }) } } - -impl TestRandom for [EpochCache; 3] { - /// Test random should generate an empty cache. - fn random_for_test(rng: &mut T) -> Self { - [ - EpochCache::default(), - EpochCache::default(), - EpochCache::default(), - ] - } -} diff --git a/eth2/types/src/beacon_state/pubkey_cache.rs b/eth2/types/src/beacon_state/pubkey_cache.rs index 22fe32694..340bdb311 100644 --- a/eth2/types/src/beacon_state/pubkey_cache.rs +++ b/eth2/types/src/beacon_state/pubkey_cache.rs @@ -1,6 +1,4 @@ -use crate::test_utils::TestRandom; use crate::*; -use rand::RngCore; use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; @@ -38,10 +36,3 @@ impl PubkeyCache { self.map.get(pubkey).cloned() } } - -impl TestRandom for PubkeyCache { - /// Test random should generate an empty cache. - fn random_for_test(rng: &mut T) -> Self { - Self::default() - } -}