Improve naming consistency in test_harness

With respect to filenames. Especially removing Test.. prefixes
This commit is contained in:
Paul Hauner 2019-02-05 16:22:07 +11:00
parent da1498fc45
commit af50c28e0f
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
8 changed files with 29 additions and 27 deletions

View File

@ -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<BeaconChain<MemoryDB, TestingSlotClock>>,
pub block_store: Arc<BeaconBlockStore<MemoryDB>>,
pub state_store: Arc<BeaconStateStore<MemoryDB>>,
pub validators: Vec<TestValidator>,
pub validators: Vec<ValidatorHarness>,
pub spec: Arc<ChainSpec>,
}
@ -91,12 +91,14 @@ impl BeaconChainHarness {
debug!("Creating validator producer and attester instances...");
// Spawn the test validator instances.
let validators: Vec<TestValidator> = keypairs
let validators: Vec<ValidatorHarness> = 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,

View File

@ -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;

View File

@ -1,6 +0,0 @@
mod direct_beacon_node;
mod direct_duties;
mod signer;
mod validator;
pub use self::validator::TestValidator;

View File

@ -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<bool>,
}
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<Signature> {
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<Signature> {
self.bls_sign(message)
}

View File

@ -0,0 +1,6 @@
mod direct_beacon_node;
mod direct_duties;
mod local_signer;
mod validator_harness;
pub use self::validator_harness::ValidatorHarness;

View File

@ -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<MemoryDB, TestingSlotClock>,
DirectDuties<MemoryDB, TestingSlotClock>,
TestSigner,
LocalSigner,
>,
pub attester: Attester<
TestingSlotClock,
DirectBeaconNode<MemoryDB, TestingSlotClock>,
DirectDuties<MemoryDB, TestingSlotClock>,
TestSigner,
LocalSigner,
>,
pub spec: Arc<ChainSpec>,
pub epoch_map: Arc<DirectDuties<MemoryDB, TestingSlotClock>>,
pub keypair: Keypair,
pub beacon_node: Arc<DirectBeaconNode<MemoryDB, TestingSlotClock>>,
pub slot_clock: Arc<TestingSlotClock>,
pub signer: Arc<TestSigner>,
pub signer: Arc<LocalSigner>,
}
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<ChainSpec>,
) -> 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()));