From 5cbb34cf6207449b14ab874505a9a7623dc8f2a9 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 16 Jan 2020 10:53:03 +1100 Subject: [PATCH] Start adding new test format --- eth2/proto_array_fork_choice/tests/test.rs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/eth2/proto_array_fork_choice/tests/test.rs b/eth2/proto_array_fork_choice/tests/test.rs index 5d8314b81c..dac9780b9f 100644 --- a/eth2/proto_array_fork_choice/tests/test.rs +++ b/eth2/proto_array_fork_choice/tests/test.rs @@ -1,6 +1,51 @@ use proto_array_fork_choice::ProtoArrayForkChoice; use types::{Epoch, Hash256, Slot}; +pub enum Operation { + FindHead { + justified_epoch: Epoch, + justified_root: Epoch, + finalized_epoch: Epoch, + justified_state_balances: Vec, + expected_head: Hash256, + }, + ProcessBlock { + slot: Slot, + root: Hash256, + parent_root: Hash256, + justified_epoch: Epoch, + finalized_epoch: Epoch, + }, + ProcessAttestation { + validator_index: usize, + block_root: Hash256, + target_epoch: Epoch, + }, +} + +pub struct ForkChoiceTester { + fork_choice: ProtoArrayForkChoice, +} + +impl ForkChoiceTester { + pub fn new( + finalized_block_slot: Slot, + justified_epoch: Epoch, + finalized_epoch: Epoch, + finalized_root: Hash256, + ) -> Self { + Self { + fork_choice: ProtoArrayForkChoice::new( + finalized_block_slot, + justified_epoch, + finalized_epoch, + finalized_root, + ) + .expect("should create fork choice"), + } + } +} + /// Gives a hash that is not the zero hash (unless i is `usize::max_value)`. fn get_hash(i: u64) -> Hash256 { Hash256::from_low_u64_be(i)