Fix block_producer naming to match attester

This commit is contained in:
Paul Hauner 2019-02-05 16:47:59 +11:00
parent 49dcb38c31
commit 6c6ee4320d
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
6 changed files with 24 additions and 24 deletions

View File

@ -213,7 +213,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::{
@ -232,10 +232,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 epoch_map = TestEpochMap::new(spec.epoch_length);
let mut epoch_map = EpochMap::new(spec.epoch_length);
let produce_slot = 100;
let produce_epoch = produce_slot / spec.epoch_length;
epoch_map.map.insert(produce_epoch, produce_slot);

View File

@ -1,12 +1,12 @@
use crate::{DutiesReader, DutiesReaderError};
use std::collections::HashMap;
pub struct TestEpochMap {
pub struct EpochMap {
epoch_length: u64,
pub map: HashMap<u64, u64>,
}
impl TestEpochMap {
impl EpochMap {
pub fn new(epoch_length: u64) -> Self {
Self {
epoch_length,
@ -15,7 +15,7 @@ impl TestEpochMap {
}
}
impl DutiesReader for TestEpochMap {
impl DutiesReader for EpochMap {
fn is_block_production_slot(&self, slot: u64) -> Result<bool, DutiesReaderError> {
let epoch = slot / self.epoch_length;
match self.map.get(&epoch) {

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_block_proposal(&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

@ -8,7 +8,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 nonce_input: RwLock<Option<PublicKey>>,
pub nonce_result: RwLock<Option<NonceResult>>,
@ -19,7 +19,7 @@ pub struct TestBeaconNode {
pub publish_result: RwLock<Option<PublishResult>>,
}
impl TestBeaconNode {
impl SimulatedBeaconNode {
/// Set the result to be returned when `produce_beacon_block` is called.
pub fn set_next_nonce_result(&self, result: NonceResult) {
*self.nonce_result.write().unwrap() = Some(result);
@ -36,12 +36,12 @@ impl TestBeaconNode {
}
}
impl BeaconNode for TestBeaconNode {
impl BeaconNode for SimulatedBeaconNode {
fn proposer_nonce(&self, pubkey: &PublicKey) -> NonceResult {
*self.nonce_input.write().unwrap() = Some(pubkey.clone());
match *self.nonce_result.read().unwrap() {
Some(ref r) => r.clone(),
None => panic!("TestBeaconNode: nonce_result == None"),
None => panic!("SimulatedBeaconNode: nonce_result == None"),
}
}
@ -50,7 +50,7 @@ impl BeaconNode for TestBeaconNode {
*self.produce_input.write().unwrap() = Some((slot, randao_reveal.clone()));
match *self.produce_result.read().unwrap() {
Some(ref r) => r.clone(),
None => panic!("TestBeaconNode: produce_result == None"),
None => panic!("SimulatedBeaconNode: produce_result == None"),
}
}
@ -59,7 +59,7 @@ impl BeaconNode for TestBeaconNode {
*self.publish_input.write().unwrap() = Some(block);
match *self.publish_result.read().unwrap() {
Some(ref r) => r.clone(),
None => panic!("TestBeaconNode: publish_result == None"),
None => panic!("SimulatedBeaconNode: publish_result == None"),
}
}
}

View File

@ -1,7 +1,7 @@
use self::block_producer_service::{BeaconBlockGrpcClient, BlockProducerService};
use self::duties::{DutiesManager, DutiesManagerService, EpochDutiesMap};
use crate::config::ClientConfig;
use block_producer::{test_utils::TestSigner, BlockProducer};
use block_producer::{test_utils::LocalSigner, BlockProducer};
use bls::Keypair;
use clap::{App, Arg};
use grpcio::{ChannelBuilder, EnvBuilder};
@ -140,7 +140,7 @@ fn main() {
let producer_thread = {
let spec = spec.clone();
let pubkey = keypair.pk.clone();
let signer = Arc::new(TestSigner::new(keypair.clone()));
let signer = Arc::new(LocalSigner::new(keypair.clone()));
let duties_map = duties_map.clone();
let slot_clock = slot_clock.clone();
let log = log.clone();