diff --git a/eth2/types/src/beacon_state/epoch_cache.rs b/eth2/types/src/beacon_state/epoch_cache.rs index ddcca0a9a..3e580eee1 100644 --- a/eth2/types/src/beacon_state/epoch_cache.rs +++ b/eth2/types/src/beacon_state/epoch_cache.rs @@ -1,5 +1,7 @@ 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)] @@ -67,3 +69,14 @@ 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 340bdb311..22fe32694 100644 --- a/eth2/types/src/beacon_state/pubkey_cache.rs +++ b/eth2/types/src/beacon_state/pubkey_cache.rs @@ -1,4 +1,6 @@ +use crate::test_utils::TestRandom; use crate::*; +use rand::RngCore; use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; @@ -36,3 +38,10 @@ 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() + } +}