From 8d8a7117961967af38648494c5339cce8bbba814 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 30 Nov 2019 14:06:49 +1100 Subject: [PATCH] Ensure chain is finalized b4 persistence tests --- beacon_node/beacon_chain/tests/persistence_tests.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/tests/persistence_tests.rs b/beacon_node/beacon_chain/tests/persistence_tests.rs index 9b89b2325e..c14affead7 100644 --- a/beacon_node/beacon_chain/tests/persistence_tests.rs +++ b/beacon_node/beacon_chain/tests/persistence_tests.rs @@ -36,7 +36,7 @@ fn get_store(db_path: &TempDir) -> Arc { #[test] fn finalizes_after_resuming_from_db() { let validator_count = 16; - let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5; + let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 8; let first_half = num_blocks_produced / 2; let db_path = tempdir().unwrap(); @@ -56,6 +56,11 @@ fn finalizes_after_resuming_from_db() { AttestationStrategy::AllValidators, ); + assert!( + harness.chain.head().beacon_state.finalized_checkpoint.epoch > 0, + "the chain should have already finalized" + ); + let latest_slot = harness.chain.slot().expect("should have a slot"); harness.chain.persist().expect("should persist the chain"); @@ -110,6 +115,9 @@ fn finalizes_after_resuming_from_db() { ); } +/// Checks that two chains are the same, for the purpose of this tests. +/// +/// Several fields that are hard/impossible to check are ignored (e.g., the store). fn assert_chains_pretty_much_the_same(a: &BeaconChain, b: &BeaconChain) { assert_eq!(a.spec, b.spec, "spec should be equal"); assert_eq!(a.op_pool, b.op_pool, "op_pool should be equal");