From 9eb662786adebce7c3e41852a525458895e8bedc Mon Sep 17 00:00:00 2001 From: Aditya Asgaonkar Date: Thu, 1 Apr 2021 06:29:01 -0700 Subject: [PATCH] Add consistency checks in on_block tests --- .../test/phase0/unittests/fork_choice/test_on_block.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_block.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_block.py index 7fa32b86c..bb5aec578 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_block.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_block.py @@ -234,6 +234,9 @@ def test_on_block_outside_safe_slots_and_multiple_better_justified(spec, state): just_block.slot = spec.compute_start_slot_at_epoch(store.justified_checkpoint.epoch) store.blocks[just_block.hash_tree_root()] = just_block + just_block_parent = store.blocks[just_block.parent_root] + assert just_block_parent.slot < just_block.slot, f"just_block_parent.slot: {just_block_parent.slot}, just_block.slot: {just_block.slot}" + # Step time past safe slots spec.on_tick(store, store.time + spec.SAFE_SLOTS_TO_UPDATE_JUSTIFIED * spec.SECONDS_PER_SLOT) assert spec.get_current_slot(store) % spec.SLOTS_PER_EPOCH >= spec.SAFE_SLOTS_TO_UPDATE_JUSTIFIED @@ -284,6 +287,9 @@ def test_on_block_outside_safe_slots_but_finality(spec, state): just_block.slot = spec.compute_start_slot_at_epoch(store.justified_checkpoint.epoch) store.blocks[just_block.hash_tree_root()] = just_block + just_block_parent = store.blocks[just_block.parent_root] + assert just_block_parent.slot < just_block.slot, f"just_block_parent.slot: {just_block_parent.slot}, just_block.slot: {just_block.slot}" + # Step time past safe slots spec.on_tick(store, store.time + spec.SAFE_SLOTS_TO_UPDATE_JUSTIFIED * spec.SECONDS_PER_SLOT) assert spec.get_current_slot(store) % spec.SLOTS_PER_EPOCH >= spec.SAFE_SLOTS_TO_UPDATE_JUSTIFIED