From c6e24572c7d68dc4b4a6097b1773635f8482ab30 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 17 Jun 2019 17:39:17 -0700 Subject: [PATCH] Improve chain harness tests --- beacon_node/beacon_chain/src/test_utils.rs | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index b2eee12e18..e7a54580df 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -205,13 +205,37 @@ mod test { #[test] fn build_two_epochs_on_genesis() { + let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5; + let harness: BeaconChainHarness< ThreadSafeReducedTree, MinimalEthSpec, > = BeaconChainHarness::new(VALIDATOR_COUNT); - for _ in 0..MinimalEthSpec::slots_per_epoch() * 2 { + for _ in 0..num_blocks_produced { harness.extend_canonical_chain(); } + + let state = &harness.chain.head().beacon_state; + + assert_eq!( + state.slot, num_blocks_produced, + "head should be at the current slot" + ); + assert_eq!( + state.current_epoch(), + num_blocks_produced / MinimalEthSpec::slots_per_epoch(), + "head should be at the expected epoch" + ); + assert_eq!( + state.current_justified_epoch, + state.current_epoch() - 1, + "the head should be justified one behind the current epoch" + ); + assert_eq!( + state.finalized_epoch, + state.current_epoch() - 1, + "the head should be finalized one behind the current epoch" + ); } }