Improve naming consistency in test_harness
With respect to filenames. Especially removing Test.. prefixes
This commit is contained in:
parent
da1498fc45
commit
af50c28e0f
@ -1,4 +1,4 @@
|
|||||||
use super::TestValidator;
|
use super::ValidatorHarness;
|
||||||
use beacon_chain::BeaconChain;
|
use beacon_chain::BeaconChain;
|
||||||
pub use beacon_chain::{CheckPoint, Error as BeaconChainError};
|
pub use beacon_chain::{CheckPoint, Error as BeaconChainError};
|
||||||
use db::{
|
use db::{
|
||||||
@ -26,7 +26,7 @@ pub struct BeaconChainHarness {
|
|||||||
pub beacon_chain: Arc<BeaconChain<MemoryDB, TestingSlotClock>>,
|
pub beacon_chain: Arc<BeaconChain<MemoryDB, TestingSlotClock>>,
|
||||||
pub block_store: Arc<BeaconBlockStore<MemoryDB>>,
|
pub block_store: Arc<BeaconBlockStore<MemoryDB>>,
|
||||||
pub state_store: Arc<BeaconStateStore<MemoryDB>>,
|
pub state_store: Arc<BeaconStateStore<MemoryDB>>,
|
||||||
pub validators: Vec<TestValidator>,
|
pub validators: Vec<ValidatorHarness>,
|
||||||
pub spec: Arc<ChainSpec>,
|
pub spec: Arc<ChainSpec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,12 +91,14 @@ impl BeaconChainHarness {
|
|||||||
debug!("Creating validator producer and attester instances...");
|
debug!("Creating validator producer and attester instances...");
|
||||||
|
|
||||||
// Spawn the test validator instances.
|
// Spawn the test validator instances.
|
||||||
let validators: Vec<TestValidator> = keypairs
|
let validators: Vec<ValidatorHarness> = keypairs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), spec.clone()))
|
.map(|keypair| {
|
||||||
|
ValidatorHarness::new(keypair.clone(), beacon_chain.clone(), spec.clone())
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
debug!("Created {} TestValidators", validators.len());
|
debug!("Created {} ValidatorHarnesss", validators.len());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
db,
|
db,
|
@ -1,5 +1,5 @@
|
|||||||
mod harness;
|
mod beacon_chain_harness;
|
||||||
mod validator;
|
mod validator_harness;
|
||||||
|
|
||||||
pub use self::harness::BeaconChainHarness;
|
pub use self::beacon_chain_harness::BeaconChainHarness;
|
||||||
pub use self::validator::TestValidator;
|
pub use self::validator_harness::ValidatorHarness;
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
mod direct_beacon_node;
|
|
||||||
mod direct_duties;
|
|
||||||
mod signer;
|
|
||||||
mod validator;
|
|
||||||
|
|
||||||
pub use self::validator::TestValidator;
|
|
@ -4,12 +4,12 @@ use std::sync::RwLock;
|
|||||||
use types::{Keypair, Signature};
|
use types::{Keypair, Signature};
|
||||||
|
|
||||||
/// A test-only struct used to perform signing for a proposer or attester.
|
/// A test-only struct used to perform signing for a proposer or attester.
|
||||||
pub struct TestSigner {
|
pub struct LocalSigner {
|
||||||
keypair: Keypair,
|
keypair: Keypair,
|
||||||
should_sign: RwLock<bool>,
|
should_sign: RwLock<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestSigner {
|
impl LocalSigner {
|
||||||
/// Produce a new TestSigner with signing enabled by default.
|
/// Produce a new TestSigner with signing enabled by default.
|
||||||
pub fn new(keypair: Keypair) -> Self {
|
pub fn new(keypair: Keypair) -> Self {
|
||||||
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> {
|
fn sign_block_proposal(&self, message: &[u8]) -> Option<Signature> {
|
||||||
self.bls_sign(message)
|
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> {
|
fn sign_attestation_message(&self, message: &[u8]) -> Option<Signature> {
|
||||||
self.bls_sign(message)
|
self.bls_sign(message)
|
||||||
}
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
mod direct_beacon_node;
|
||||||
|
mod direct_duties;
|
||||||
|
mod local_signer;
|
||||||
|
mod validator_harness;
|
||||||
|
|
||||||
|
pub use self::validator_harness::ValidatorHarness;
|
@ -1,6 +1,6 @@
|
|||||||
use super::direct_beacon_node::DirectBeaconNode;
|
use super::direct_beacon_node::DirectBeaconNode;
|
||||||
use super::direct_duties::DirectDuties;
|
use super::direct_duties::DirectDuties;
|
||||||
use super::signer::TestSigner;
|
use super::local_signer::LocalSigner;
|
||||||
use attester::PollOutcome as AttestationPollOutcome;
|
use attester::PollOutcome as AttestationPollOutcome;
|
||||||
use attester::{Attester, Error as AttestationPollError};
|
use attester::{Attester, Error as AttestationPollError};
|
||||||
use beacon_chain::BeaconChain;
|
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
|
/// 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
|
/// testing that the core proposer and attester logic is functioning. Also for supporting beacon
|
||||||
/// chain tests.
|
/// chain tests.
|
||||||
pub struct TestValidator {
|
pub struct ValidatorHarness {
|
||||||
pub block_producer: BlockProducer<
|
pub block_producer: BlockProducer<
|
||||||
TestingSlotClock,
|
TestingSlotClock,
|
||||||
DirectBeaconNode<MemoryDB, TestingSlotClock>,
|
DirectBeaconNode<MemoryDB, TestingSlotClock>,
|
||||||
DirectDuties<MemoryDB, TestingSlotClock>,
|
DirectDuties<MemoryDB, TestingSlotClock>,
|
||||||
TestSigner,
|
LocalSigner,
|
||||||
>,
|
>,
|
||||||
pub attester: Attester<
|
pub attester: Attester<
|
||||||
TestingSlotClock,
|
TestingSlotClock,
|
||||||
DirectBeaconNode<MemoryDB, TestingSlotClock>,
|
DirectBeaconNode<MemoryDB, TestingSlotClock>,
|
||||||
DirectDuties<MemoryDB, TestingSlotClock>,
|
DirectDuties<MemoryDB, TestingSlotClock>,
|
||||||
TestSigner,
|
LocalSigner,
|
||||||
>,
|
>,
|
||||||
pub spec: Arc<ChainSpec>,
|
pub spec: Arc<ChainSpec>,
|
||||||
pub epoch_map: Arc<DirectDuties<MemoryDB, TestingSlotClock>>,
|
pub epoch_map: Arc<DirectDuties<MemoryDB, TestingSlotClock>>,
|
||||||
pub keypair: Keypair,
|
pub keypair: Keypair,
|
||||||
pub beacon_node: Arc<DirectBeaconNode<MemoryDB, TestingSlotClock>>,
|
pub beacon_node: Arc<DirectBeaconNode<MemoryDB, TestingSlotClock>>,
|
||||||
pub slot_clock: Arc<TestingSlotClock>,
|
pub slot_clock: Arc<TestingSlotClock>,
|
||||||
pub signer: Arc<TestSigner>,
|
pub signer: Arc<LocalSigner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestValidator {
|
impl ValidatorHarness {
|
||||||
/// Create a new TestValidator that signs with the given keypair, operates per the given spec and connects to the
|
/// Create a new ValidatorHarness that signs with the given keypair, operates per the given spec and connects to the
|
||||||
/// supplied beacon node.
|
/// supplied beacon node.
|
||||||
///
|
///
|
||||||
/// A `BlockProducer` and `Attester` is created..
|
/// A `BlockProducer` and `Attester` is created..
|
||||||
@ -60,7 +60,7 @@ impl TestValidator {
|
|||||||
spec: Arc<ChainSpec>,
|
spec: Arc<ChainSpec>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let slot_clock = Arc::new(TestingSlotClock::new(spec.genesis_slot));
|
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 beacon_node = Arc::new(DirectBeaconNode::new(beacon_chain.clone()));
|
||||||
let epoch_map = Arc::new(DirectDuties::new(keypair.pk.clone(), beacon_chain.clone()));
|
let epoch_map = Arc::new(DirectDuties::new(keypair.pk.clone(), beacon_chain.clone()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user