mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
Move test defs into crate
This commit is contained in:
@@ -1,18 +1,6 @@
|
|||||||
use proto_array_fork_choice::ProtoArrayForkChoice;
|
use crate::ProtoArrayForkChoice;
|
||||||
use types::{Epoch, Hash256, Slot};
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Operation {
|
pub enum Operation {
|
||||||
FindHead {
|
FindHead {
|
||||||
@@ -57,7 +45,7 @@ pub struct ForkChoiceTestDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ForkChoiceTestDefinition {
|
impl ForkChoiceTestDefinition {
|
||||||
fn run(self) {
|
pub fn run(self) {
|
||||||
let fork_choice = ProtoArrayForkChoice::new(
|
let fork_choice = ProtoArrayForkChoice::new(
|
||||||
self.finalized_block_slot,
|
self.finalized_block_slot,
|
||||||
self.justified_epoch,
|
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 balances = vec![0; 16];
|
||||||
|
|
||||||
let operations = vec![
|
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 balances = vec![1; 2];
|
||||||
let mut ops = vec![];
|
let mut ops = vec![];
|
||||||
|
|
||||||
@@ -1097,3 +1085,19 @@ fn get_votes_test_definition() -> ForkChoiceTestDefinition {
|
|||||||
operations: ops,
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod fork_choice_test_definition;
|
||||||
mod proto_array;
|
mod proto_array;
|
||||||
mod ssz_container;
|
mod ssz_container;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user