Move test defs into crate

This commit is contained in:
Paul Hauner
2020-01-16 13:32:37 +11:00
parent c33d358cc9
commit 72dc6db9dd
2 changed files with 21 additions and 16 deletions

View File

@@ -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();
}
}

View File

@@ -1,3 +1,4 @@
pub mod fork_choice_test_definition;
mod proto_array;
mod ssz_container;