diff --git a/eth2/attester/src/lib.rs b/eth2/attester/src/lib.rs index 447bcb9ea..4dda24570 100644 --- a/eth2/attester/src/lib.rs +++ b/eth2/attester/src/lib.rs @@ -170,7 +170,7 @@ impl From for Error { #[cfg(test)] mod tests { - use super::test_utils::{TestBeaconNode, TestEpochMap, TestSigner}; + use super::test_utils::{EpochMap, LocalSigner, SimulatedBeaconNode}; use super::*; use slot_clock::TestingSlotClock; use types::{ @@ -189,10 +189,10 @@ mod tests { let spec = Arc::new(ChainSpec::foundation()); let slot_clock = Arc::new(TestingSlotClock::new(0)); - let beacon_node = Arc::new(TestBeaconNode::default()); - let signer = Arc::new(TestSigner::new(Keypair::random())); + let beacon_node = Arc::new(SimulatedBeaconNode::default()); + let signer = Arc::new(LocalSigner::new(Keypair::random())); - let mut duties = TestEpochMap::new(spec.epoch_length); + let mut duties = EpochMap::new(spec.epoch_length); let attest_slot = 100; let attest_epoch = attest_slot / spec.epoch_length; let attest_shard = 12; diff --git a/eth2/attester/src/test_utils/epoch_map.rs b/eth2/attester/src/test_utils/epoch_map.rs index 9f44ecf1a..88e36c93c 100644 --- a/eth2/attester/src/test_utils/epoch_map.rs +++ b/eth2/attester/src/test_utils/epoch_map.rs @@ -1,13 +1,13 @@ use crate::{DutiesReader, DutiesReaderError}; use std::collections::HashMap; -pub struct TestEpochMap { +pub struct EpochMap { epoch_length: u64, validator_index: Option, map: HashMap, } -impl TestEpochMap { +impl EpochMap { pub fn new(epoch_length: u64) -> Self { Self { epoch_length, @@ -27,7 +27,7 @@ impl TestEpochMap { } } -impl DutiesReader for TestEpochMap { +impl DutiesReader for EpochMap { fn attestation_shard(&self, slot: u64) -> Result, DutiesReaderError> { let epoch = slot / self.epoch_length; diff --git a/eth2/attester/src/test_utils/signer.rs b/eth2/attester/src/test_utils/local_signer.rs similarity index 83% rename from eth2/attester/src/test_utils/signer.rs rename to eth2/attester/src/test_utils/local_signer.rs index 185dec278..c256d1050 100644 --- a/eth2/attester/src/test_utils/signer.rs +++ b/eth2/attester/src/test_utils/local_signer.rs @@ -3,13 +3,13 @@ use std::sync::RwLock; use types::{Keypair, Signature}; /// A test-only struct used to simulate a Beacon Node. -pub struct TestSigner { +pub struct LocalSigner { keypair: Keypair, should_sign: RwLock, } -impl TestSigner { - /// Produce a new TestSigner with signing enabled by default. +impl LocalSigner { + /// Produce a new LocalSigner with signing enabled by default. pub fn new(keypair: Keypair) -> Self { Self { keypair, @@ -24,7 +24,7 @@ impl TestSigner { } } -impl Signer for TestSigner { +impl Signer for LocalSigner { fn sign_attestation_message(&self, message: &[u8]) -> Option { Some(Signature::new(message, &self.keypair.sk)) } diff --git a/eth2/attester/src/test_utils/mod.rs b/eth2/attester/src/test_utils/mod.rs index 0dd384b12..481247dd0 100644 --- a/eth2/attester/src/test_utils/mod.rs +++ b/eth2/attester/src/test_utils/mod.rs @@ -1,7 +1,7 @@ -mod beacon_node; mod epoch_map; -mod signer; +mod local_signer; +mod simulated_beacon_node; -pub use self::beacon_node::TestBeaconNode; -pub use self::epoch_map::TestEpochMap; -pub use self::signer::TestSigner; +pub use self::epoch_map::EpochMap; +pub use self::local_signer::LocalSigner; +pub use self::simulated_beacon_node::SimulatedBeaconNode; diff --git a/eth2/attester/src/test_utils/beacon_node.rs b/eth2/attester/src/test_utils/simulated_beacon_node.rs similarity index 93% rename from eth2/attester/src/test_utils/beacon_node.rs rename to eth2/attester/src/test_utils/simulated_beacon_node.rs index 5b4061c60..2f14c9fd3 100644 --- a/eth2/attester/src/test_utils/beacon_node.rs +++ b/eth2/attester/src/test_utils/simulated_beacon_node.rs @@ -7,7 +7,7 @@ type PublishResult = Result; /// A test-only struct used to simulate a Beacon Node. #[derive(Default)] -pub struct TestBeaconNode { +pub struct SimulatedBeaconNode { pub produce_input: RwLock>, pub produce_result: RwLock>, @@ -15,7 +15,7 @@ pub struct TestBeaconNode { pub publish_result: RwLock>, } -impl TestBeaconNode { +impl SimulatedBeaconNode { pub fn set_next_produce_result(&self, result: ProduceResult) { *self.produce_result.write().unwrap() = Some(result); } @@ -25,7 +25,7 @@ impl TestBeaconNode { } } -impl BeaconNode for TestBeaconNode { +impl BeaconNode for SimulatedBeaconNode { fn produce_attestation_data(&self, slot: u64, shard: u64) -> ProduceResult { *self.produce_input.write().unwrap() = Some((slot, shard)); match *self.produce_result.read().unwrap() {