From af50c28e0f593295bd6ef3b919c2fc6b0e704e74 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 5 Feb 2019 16:22:07 +1100 Subject: [PATCH] Improve naming consistency in `test_harness` With respect to filenames. Especially removing Test.. prefixes --- .../src/{harness.rs => beacon_chain_harness.rs} | 12 +++++++----- beacon_node/beacon_chain/test_harness/src/lib.rs | 8 ++++---- .../test_harness/src/validator/mod.rs | 6 ------ .../direct_beacon_node.rs | 0 .../direct_duties.rs | 0 .../local_signer.rs} | 8 ++++---- .../test_harness/src/validator_harness/mod.rs | 6 ++++++ .../validator_harness.rs} | 16 ++++++++-------- 8 files changed, 29 insertions(+), 27 deletions(-) rename beacon_node/beacon_chain/test_harness/src/{harness.rs => beacon_chain_harness.rs} (95%) delete mode 100644 beacon_node/beacon_chain/test_harness/src/validator/mod.rs rename beacon_node/beacon_chain/test_harness/src/{validator => validator_harness}/direct_beacon_node.rs (100%) rename beacon_node/beacon_chain/test_harness/src/{validator => validator_harness}/direct_duties.rs (100%) rename beacon_node/beacon_chain/test_harness/src/{validator/signer.rs => validator_harness/local_signer.rs} (90%) create mode 100644 beacon_node/beacon_chain/test_harness/src/validator_harness/mod.rs rename beacon_node/beacon_chain/test_harness/src/{validator/validator.rs => validator_harness/validator_harness.rs} (92%) diff --git a/beacon_node/beacon_chain/test_harness/src/harness.rs b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs similarity index 95% rename from beacon_node/beacon_chain/test_harness/src/harness.rs rename to beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs index 12ed40755c..64d18b4beb 100644 --- a/beacon_node/beacon_chain/test_harness/src/harness.rs +++ b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs @@ -1,4 +1,4 @@ -use super::TestValidator; +use super::ValidatorHarness; use beacon_chain::BeaconChain; pub use beacon_chain::{CheckPoint, Error as BeaconChainError}; use db::{ @@ -26,7 +26,7 @@ pub struct BeaconChainHarness { pub beacon_chain: Arc>, pub block_store: Arc>, pub state_store: Arc>, - pub validators: Vec, + pub validators: Vec, pub spec: Arc, } @@ -91,12 +91,14 @@ impl BeaconChainHarness { debug!("Creating validator producer and attester instances..."); // Spawn the test validator instances. - let validators: Vec = keypairs + let validators: Vec = keypairs .iter() - .map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), spec.clone())) + .map(|keypair| { + ValidatorHarness::new(keypair.clone(), beacon_chain.clone(), spec.clone()) + }) .collect(); - debug!("Created {} TestValidators", validators.len()); + debug!("Created {} ValidatorHarnesss", validators.len()); Self { db, diff --git a/beacon_node/beacon_chain/test_harness/src/lib.rs b/beacon_node/beacon_chain/test_harness/src/lib.rs index 71f9a88558..b04fc69963 100644 --- a/beacon_node/beacon_chain/test_harness/src/lib.rs +++ b/beacon_node/beacon_chain/test_harness/src/lib.rs @@ -1,5 +1,5 @@ -mod harness; -mod validator; +mod beacon_chain_harness; +mod validator_harness; -pub use self::harness::BeaconChainHarness; -pub use self::validator::TestValidator; +pub use self::beacon_chain_harness::BeaconChainHarness; +pub use self::validator_harness::ValidatorHarness; diff --git a/beacon_node/beacon_chain/test_harness/src/validator/mod.rs b/beacon_node/beacon_chain/test_harness/src/validator/mod.rs deleted file mode 100644 index 3a0d53395e..0000000000 --- a/beacon_node/beacon_chain/test_harness/src/validator/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod direct_beacon_node; -mod direct_duties; -mod signer; -mod validator; - -pub use self::validator::TestValidator; diff --git a/beacon_node/beacon_chain/test_harness/src/validator/direct_beacon_node.rs b/beacon_node/beacon_chain/test_harness/src/validator_harness/direct_beacon_node.rs similarity index 100% rename from beacon_node/beacon_chain/test_harness/src/validator/direct_beacon_node.rs rename to beacon_node/beacon_chain/test_harness/src/validator_harness/direct_beacon_node.rs diff --git a/beacon_node/beacon_chain/test_harness/src/validator/direct_duties.rs b/beacon_node/beacon_chain/test_harness/src/validator_harness/direct_duties.rs similarity index 100% rename from beacon_node/beacon_chain/test_harness/src/validator/direct_duties.rs rename to beacon_node/beacon_chain/test_harness/src/validator_harness/direct_duties.rs diff --git a/beacon_node/beacon_chain/test_harness/src/validator/signer.rs b/beacon_node/beacon_chain/test_harness/src/validator_harness/local_signer.rs similarity index 90% rename from beacon_node/beacon_chain/test_harness/src/validator/signer.rs rename to beacon_node/beacon_chain/test_harness/src/validator_harness/local_signer.rs index 6e63c7f99e..8e901b057b 100644 --- a/beacon_node/beacon_chain/test_harness/src/validator/signer.rs +++ b/beacon_node/beacon_chain/test_harness/src/validator_harness/local_signer.rs @@ -4,12 +4,12 @@ use std::sync::RwLock; use types::{Keypair, Signature}; /// A test-only struct used to perform signing for a proposer or attester. -pub struct TestSigner { +pub struct LocalSigner { keypair: Keypair, should_sign: RwLock, } -impl TestSigner { +impl LocalSigner { /// Produce a new TestSigner with signing enabled by default. pub fn new(keypair: Keypair) -> Self { Self { @@ -30,7 +30,7 @@ impl TestSigner { } } -impl BlockProposerSigner for TestSigner { +impl BlockProposerSigner for LocalSigner { fn sign_block_proposal(&self, message: &[u8]) -> Option { self.bls_sign(message) } @@ -40,7 +40,7 @@ impl BlockProposerSigner for TestSigner { } } -impl AttesterSigner for TestSigner { +impl AttesterSigner for LocalSigner { fn sign_attestation_message(&self, message: &[u8]) -> Option { self.bls_sign(message) } diff --git a/beacon_node/beacon_chain/test_harness/src/validator_harness/mod.rs b/beacon_node/beacon_chain/test_harness/src/validator_harness/mod.rs new file mode 100644 index 0000000000..837334ade5 --- /dev/null +++ b/beacon_node/beacon_chain/test_harness/src/validator_harness/mod.rs @@ -0,0 +1,6 @@ +mod direct_beacon_node; +mod direct_duties; +mod local_signer; +mod validator_harness; + +pub use self::validator_harness::ValidatorHarness; diff --git a/beacon_node/beacon_chain/test_harness/src/validator/validator.rs b/beacon_node/beacon_chain/test_harness/src/validator_harness/validator_harness.rs similarity index 92% rename from beacon_node/beacon_chain/test_harness/src/validator/validator.rs rename to beacon_node/beacon_chain/test_harness/src/validator_harness/validator_harness.rs index d33a0412b1..986d843bb7 100644 --- a/beacon_node/beacon_chain/test_harness/src/validator/validator.rs +++ b/beacon_node/beacon_chain/test_harness/src/validator_harness/validator_harness.rs @@ -1,6 +1,6 @@ use super::direct_beacon_node::DirectBeaconNode; use super::direct_duties::DirectDuties; -use super::signer::TestSigner; +use super::local_signer::LocalSigner; use attester::PollOutcome as AttestationPollOutcome; use attester::{Attester, Error as AttestationPollError}; use beacon_chain::BeaconChain; @@ -28,29 +28,29 @@ pub enum AttestationProduceError { /// The test validator connects directly to a borrowed `BeaconChain` struct. It is useful for /// testing that the core proposer and attester logic is functioning. Also for supporting beacon /// chain tests. -pub struct TestValidator { +pub struct ValidatorHarness { pub block_producer: BlockProducer< TestingSlotClock, DirectBeaconNode, DirectDuties, - TestSigner, + LocalSigner, >, pub attester: Attester< TestingSlotClock, DirectBeaconNode, DirectDuties, - TestSigner, + LocalSigner, >, pub spec: Arc, pub epoch_map: Arc>, pub keypair: Keypair, pub beacon_node: Arc>, pub slot_clock: Arc, - pub signer: Arc, + pub signer: Arc, } -impl TestValidator { - /// Create a new TestValidator that signs with the given keypair, operates per the given spec and connects to the +impl ValidatorHarness { + /// Create a new ValidatorHarness that signs with the given keypair, operates per the given spec and connects to the /// supplied beacon node. /// /// A `BlockProducer` and `Attester` is created.. @@ -60,7 +60,7 @@ impl TestValidator { spec: Arc, ) -> Self { let slot_clock = Arc::new(TestingSlotClock::new(spec.genesis_slot)); - let signer = Arc::new(TestSigner::new(keypair.clone())); + let signer = Arc::new(LocalSigner::new(keypair.clone())); let beacon_node = Arc::new(DirectBeaconNode::new(beacon_chain.clone())); let epoch_map = Arc::new(DirectDuties::new(keypair.pk.clone(), beacon_chain.clone()));