From 72dc6db9ddb311fbbea0d538df73ee96a6ef97cb Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 16 Jan 2020 13:32:37 +1100 Subject: [PATCH] Move test defs into crate --- .../fork_choice_test_definition.rs} | 36 ++++++++++--------- eth2/proto_array_fork_choice/src/lib.rs | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) rename eth2/proto_array_fork_choice/{tests/test.rs => src/fork_choice_test_definition.rs} (98%) diff --git a/eth2/proto_array_fork_choice/tests/test.rs b/eth2/proto_array_fork_choice/src/fork_choice_test_definition.rs similarity index 98% rename from eth2/proto_array_fork_choice/tests/test.rs rename to eth2/proto_array_fork_choice/src/fork_choice_test_definition.rs index 8a833745d0..d976579958 100644 --- a/eth2/proto_array_fork_choice/tests/test.rs +++ b/eth2/proto_array_fork_choice/src/fork_choice_test_definition.rs @@ -1,18 +1,6 @@ -use proto_array_fork_choice::ProtoArrayForkChoice; +use crate::ProtoArrayForkChoice; use types::{Epoch, Hash256, Slot}; -#[test] -fn no_votes() { - let test = get_no_votes_test_definition(); - test.run(); -} - -#[test] -fn votes() { - let test = get_votes_test_definition(); - test.run(); -} - #[derive(Debug, Clone)] pub enum Operation { FindHead { @@ -57,7 +45,7 @@ pub struct ForkChoiceTestDefinition { } impl ForkChoiceTestDefinition { - fn run(self) { + pub fn run(self) { let fork_choice = ProtoArrayForkChoice::new( self.finalized_block_slot, self.justified_epoch, @@ -184,7 +172,7 @@ fn check_bytes_round_trip(original: &ProtoArrayForkChoice) { ); } -fn get_no_votes_test_definition() -> ForkChoiceTestDefinition { +pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition { let balances = vec![0; 16]; let operations = vec![ @@ -410,7 +398,7 @@ fn get_no_votes_test_definition() -> ForkChoiceTestDefinition { } } -fn get_votes_test_definition() -> ForkChoiceTestDefinition { +pub fn get_votes_test_definition() -> ForkChoiceTestDefinition { let mut balances = vec![1; 2]; let mut ops = vec![]; @@ -1097,3 +1085,19 @@ fn get_votes_test_definition() -> ForkChoiceTestDefinition { operations: ops, } } + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn no_votes() { + let test = get_no_votes_test_definition(); + test.run(); + } + + #[test] + fn votes() { + let test = get_votes_test_definition(); + test.run(); + } +} diff --git a/eth2/proto_array_fork_choice/src/lib.rs b/eth2/proto_array_fork_choice/src/lib.rs index 267f35e37a..19c1948bd8 100644 --- a/eth2/proto_array_fork_choice/src/lib.rs +++ b/eth2/proto_array_fork_choice/src/lib.rs @@ -1,3 +1,4 @@ +pub mod fork_choice_test_definition; mod proto_array; mod ssz_container;