Update test format and output should_override_forkchoice_update result

This commit is contained in:
Hsiao-Wei Wang 2023-10-25 02:10:55 +08:00
parent 3f8d8feb69
commit 35d444b9d2
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
3 changed files with 21 additions and 3 deletions

View File

@ -17,6 +17,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,
)
@ -56,7 +57,15 @@ def test_should_override_forkchoice_update__false(spec, state):
current_time = slot * spec.config.SECONDS_PER_SLOT + store.genesis_time
on_tick_and_append_step(spec, store, current_time, test_steps)
assert not spec.should_override_forkchoice_update(store, head_root)
should_override = spec.should_override_forkchoice_update(store, head_root)
assert not should_override
output_store_checks(spec, store, test_steps)
test_steps.append({
'checks': {
'should_override_forkchoice_update': should_override,
}
})
yield 'steps', test_steps
@ -155,8 +164,14 @@ def test_should_override_forkchoice_update__true(spec, state):
assert spec.is_head_weak(store, head_root)
assert spec.is_parent_strong(store, parent_root)
assert spec.should_override_forkchoice_update(store, head_root)
should_override = spec.should_override_forkchoice_update(store, head_root)
assert should_override
# TODO: export the `should_override_forkchoice_update` result to test vectors?
output_store_checks(spec, store, test_steps)
test_steps.append({
'checks': {
'should_override_forkchoice_update': should_override,
}
})
yield 'steps', test_steps

View File

@ -177,6 +177,7 @@ 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)`
```
For example:

View File

@ -10,12 +10,14 @@ if __name__ == "__main__":
'ex_ante',
'reorg',
'withholding',
'get_proposer_head',
]}
# For merge `on_merge_block` test kind added with `pow_block_N.ssz` files with several
# 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',
]}
bellatrix_mods = combine_mods(_new_bellatrix_mods, altair_mods)
capella_mods = bellatrix_mods # No additional Capella specific fork choice tests