Fix naming consistency with attester crate.

Adjusted naming of files to ensure they match the name of the struct.
Also change the name of some structs so they don't look like tests.
This commit is contained in:
Paul Hauner 2019-02-05 16:41:18 +11:00
parent af50c28e0f
commit 49dcb38c31
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
5 changed files with 19 additions and 19 deletions

View File

@ -170,7 +170,7 @@ impl From<BeaconNodeError> 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;

View File

@ -1,13 +1,13 @@
use crate::{DutiesReader, DutiesReaderError};
use std::collections::HashMap;
pub struct TestEpochMap {
pub struct EpochMap {
epoch_length: u64,
validator_index: Option<u64>,
map: HashMap<u64, (u64, u64)>,
}
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<Option<u64>, DutiesReaderError> {
let epoch = slot / self.epoch_length;

View File

@ -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<bool>,
}
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<Signature> {
Some(Signature::new(message, &self.keypair.sk))
}

View File

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

View File

@ -7,7 +7,7 @@ type PublishResult = Result<PublishOutcome, BeaconNodeError>;
/// A test-only struct used to simulate a Beacon Node.
#[derive(Default)]
pub struct TestBeaconNode {
pub struct SimulatedBeaconNode {
pub produce_input: RwLock<Option<(u64, u64)>>,
pub produce_result: RwLock<Option<ProduceResult>>,
@ -15,7 +15,7 @@ pub struct TestBeaconNode {
pub publish_result: RwLock<Option<PublishResult>>,
}
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() {