diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_reorg.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_reorg.py rename to tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py index 083b292c0..249e76b08 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py @@ -1,3 +1,4 @@ +from eth_utils import encode_hex from eth2spec.test.context import ( spec_state_test, with_altair_and_later, @@ -13,6 +14,7 @@ from eth2spec.test.helpers.fork_choice import ( apply_next_slots_with_attestations, get_genesis_forkchoice_store_and_block, on_tick_and_append_step, + output_store_checks, tick_and_add_block, tick_and_run_on_attestation, ) @@ -51,9 +53,15 @@ def test_basic_is_head_root(spec, state): current_time = slot * spec.config.SECONDS_PER_SLOT + store.genesis_time on_tick_and_append_step(spec, store, current_time, test_steps) proposer_head = spec.get_proposer_head(store, head_root, slot) - assert proposer_head == head_root + output_store_checks(spec, store, test_steps) + test_steps.append({ + 'checks': { + 'get_proposer_head': encode_hex(proposer_head), + } + }) + yield 'steps', test_steps @@ -149,6 +157,11 @@ def test_basic_is_parent_root(spec, state): proposer_head = spec.get_proposer_head(store, head_root, state.slot) assert proposer_head == parent_root - # TODO: export the `proposer_head` result to test vectors? + output_store_checks(spec, store, test_steps) + test_steps.append({ + 'checks': { + 'get_proposer_head': encode_hex(proposer_head), + } + }) yield 'steps', test_steps diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index 3bd773f52..1d8b9cfb3 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -159,7 +159,7 @@ The checks to verify the current status of `store`. checks: {: value} -- the assertions. ``` -`` is the field member or property of [`Store`](../../../specs/phase0/fork-choice.md#store) object that maintained by client implementation. Currently, the possible fields included: +`` is the field member or property of [`Store`](../../../specs/phase0/fork-choice.md#store) object that maintained by client implementation. The fields include: ```yaml head: { @@ -177,7 +177,13 @@ finalized_checkpoint: { root: string, -- Encoded 32-byte value from store.finalized_checkpoint.root } proposer_boost_root: string -- Encoded 32-byte value from store.proposer_boost_root -should_override_forkchoice_update: bool -- [New in Bellatrix] the result of `should_override_forkchoice_update(store, head_root)` +``` + +Additionally, these fields if `get_proposer_head` and `should_override_forkchoice_update` features are implemented: + +```yaml +get_proposer_head: string -- Encoded 32-byte value from get_proposer_head(store) +should_override_forkchoice_update: bool -- [New in Bellatrix] the result of `should_override_forkchoice_update(store, head_root)`, where head_root is the result value from get_head(store) ``` For example: @@ -188,6 +194,8 @@ For example: justified_checkpoint: {epoch: 3, root: '0xc25faab4acab38d3560864ca01e4d5cc4dc2cd473da053fbc03c2669143a2de4'} finalized_checkpoint: {epoch: 2, root: '0x40d32d6283ec11c53317a46808bc88f55657d93b95a1af920403187accf48f4f'} proposer_boost_root: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' + get_proposer_head: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' + should_override_forkchoice_update: false ``` *Note*: Each `checks` step may include one or multiple items. Each item has to be checked against the current store. diff --git a/tests/generators/fork_choice/main.py b/tests/generators/fork_choice/main.py index e8d19eb09..df117ccd1 100644 --- a/tests/generators/fork_choice/main.py +++ b/tests/generators/fork_choice/main.py @@ -17,7 +17,7 @@ if __name__ == "__main__": # PowBlock's which should be resolved by `get_pow_block(hash: Hash32) -> PowBlock` function _new_bellatrix_mods = {key: 'eth2spec.test.bellatrix.fork_choice.test_' + key for key in [ 'on_merge_block', - 'reorg', + 'should_override_forkchoice_update', ]} bellatrix_mods = combine_mods(_new_bellatrix_mods, altair_mods) capella_mods = bellatrix_mods # No additional Capella specific fork choice tests