From ecbe9190b942a45f5e7eb814dfc84ade3f4269ac Mon Sep 17 00:00:00 2001 From: Aditya Asgaonkar Date: Tue, 23 Nov 2021 07:20:54 -0800 Subject: [PATCH] Apply HWW code's review - properly update test steps --- .../test/phase0/fork_choice/test_get_head.py | 10 ++++--- .../test/phase0/fork_choice/test_on_block.py | 29 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py index fccf1d636..83e342e08 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py @@ -304,21 +304,23 @@ def test_proposer_boost_correct_head(spec, state): assert spec.hash_tree_root(block_1) < spec.hash_tree_root(block_2) # Tick to block_1 slot time - spec.on_tick(store, store.genesis_time + block_1.slot * spec.config.SECONDS_PER_SLOT) + time = store.genesis_time + block_1.slot * spec.config.SECONDS_PER_SLOT + on_tick_and_append_step(spec, store, time, test_steps) # Process block_2 - yield from tick_and_add_block(spec, store, signed_block_2, test_steps) + yield from add_block(spec, store, signed_block_2, test_steps) assert store.proposer_boost_root == spec.Root() assert spec.get_head(store) == spec.hash_tree_root(block_2) # Process block_1 on timely arrival # The head should temporarily change to block_1 - yield from tick_and_add_block(spec, store, signed_block_1, test_steps) + yield from add_block(spec, store, signed_block_1, test_steps) assert store.proposer_boost_root == spec.hash_tree_root(block_1) assert spec.get_head(store) == spec.hash_tree_root(block_1) # After block_1.slot, the head should revert to block_2 - spec.on_tick(store, store.genesis_time + (block_1.slot + 1) * spec.config.SECONDS_PER_SLOT) + time = store.genesis_time + (block_1.slot + 1) * spec.config.SECONDS_PER_SLOT + on_tick_and_append_step(spec, store, time, test_steps) assert store.proposer_boost_root == spec.Root() assert spec.get_head(store) == spec.hash_tree_root(block_2) diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py index f234125e0..5c3ba89de 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py @@ -723,15 +723,17 @@ def test_proposer_boost(spec, state): signed_block = state_transition_and_sign_block(spec, state, block) # Process block on timely arrival just before end of boost interval - spec.on_tick(store, store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + - spec.config.SECONDS_PER_SLOT // spec.INTERVALS_PER_SLOT - 1) - yield from tick_and_add_block(spec, store, signed_block, test_steps) + time = (store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + + spec.config.SECONDS_PER_SLOT // spec.INTERVALS_PER_SLOT - 1) + on_tick_and_append_step(spec, store, time, test_steps) + yield from add_block(spec, store, signed_block, test_steps) assert store.proposer_boost_root == spec.hash_tree_root(block) assert spec.get_latest_attesting_balance(store, spec.hash_tree_root(block)) > 0 # Ensure that boost is removed after slot is over - spec.on_tick(store, store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + - spec.config.SECONDS_PER_SLOT) + time = (store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + + spec.config.SECONDS_PER_SLOT) + on_tick_and_append_step(spec, store, time, test_steps) assert store.proposer_boost_root == spec.Root() assert spec.get_latest_attesting_balance(store, spec.hash_tree_root(block)) == 0 @@ -740,14 +742,16 @@ def test_proposer_boost(spec, state): signed_block = state_transition_and_sign_block(spec, state, block) # Process block on timely arrival at start of boost interval - spec.on_tick(store, store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT) - yield from tick_and_add_block(spec, store, signed_block, test_steps) + time = (store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT) + on_tick_and_append_step(spec, store, time, test_steps) + yield from add_block(spec, store, signed_block, test_steps) assert store.proposer_boost_root == spec.hash_tree_root(block) assert spec.get_latest_attesting_balance(store, spec.hash_tree_root(block)) > 0 # Ensure that boost is removed after slot is over - spec.on_tick(store, store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + - spec.config.SECONDS_PER_SLOT) + time = (store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + + spec.config.SECONDS_PER_SLOT) + on_tick_and_append_step(spec, store, time, test_steps) assert store.proposer_boost_root == spec.Root() assert spec.get_latest_attesting_balance(store, spec.hash_tree_root(block)) == 0 @@ -772,9 +776,10 @@ def test_proposer_boost_root_same_slot_untimely_block(spec, state): signed_block = state_transition_and_sign_block(spec, state, block) # Process block on untimely arrival in the same slot - spec.on_tick(store, store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + - spec.config.SECONDS_PER_SLOT // spec.INTERVALS_PER_SLOT) - yield from tick_and_add_block(spec, store, signed_block, test_steps) + time = (store.genesis_time + block.slot * spec.config.SECONDS_PER_SLOT + + spec.config.SECONDS_PER_SLOT // spec.INTERVALS_PER_SLOT) + on_tick_and_append_step(spec, store, time, test_steps) + yield from add_block(spec, store, signed_block, test_steps) assert store.proposer_boost_root == spec.Root() yield 'steps', test_steps