Combine the conflicting handler names

This commit is contained in:
Hsiao-Wei Wang 2021-10-07 02:11:50 +08:00
parent fea3702b3d
commit dcdbff0728
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
4 changed files with 40 additions and 14 deletions

View File

@ -109,3 +109,24 @@ def run_state_test_generators(runner_name: str,
preset_name=preset_name,
all_mods=all_mods,
))
def combine_mods(dict_1, dict_2):
"""
Return the merged dicts, where the result value would be a list of the values from two dicts.
"""
# The duplicate dict_1 items would be ignored here.
dict_3 = {**dict_1, **dict_2}
intersection = list(dict_1.keys() & dict_2.keys())
for key in intersection:
# To list
if not isinstance(dict_3[key], List):
dict_3[key] = [dict_3[key], ]
# Append dict_1 value to list
if isinstance(dict_1[key], List):
dict_3[key] += dict_1[key]
else:
dict_3[key].append(dict_1[key])
return dict_3

View File

@ -11,7 +11,7 @@ from eth2spec.test.context import (
@with_merge_and_later
@spec_state_test
def test_empty_block_transition(spec, state):
def test_empty_block_transition_no_tx(spec, state):
yield 'pre', state
block = build_empty_block_for_next_slot(spec, state)

View File

@ -1,4 +1,4 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, MERGE
@ -7,14 +7,15 @@ if __name__ == "__main__":
'initialization',
'validity',
]}
altair_mods = phase_0_mods
# we have new unconditional lines in `initialize_beacon_state_from_eth1` and we want to test it
merge_mods = {
**{key: 'eth2spec.test.merge.genesis.test_' + key for key in [
'initialization',
]},
**altair_mods,
}
altair_mods = phase_0_mods
_new_merge_mods = {key: 'eth2spec.test.merge.genesis.test_' + key for key in [
'initialization',
]}
merge_mods = combine_mods(_new_merge_mods, altair_mods)
all_mods = {
PHASE0: phase_0_mods,
ALTAIR: altair_mods,

View File

@ -1,5 +1,5 @@
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, MERGE
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods
if __name__ == "__main__":
@ -7,12 +7,16 @@ if __name__ == "__main__":
'blocks',
'slots',
]}
altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [
_new_altair_mods = {key: 'eth2spec.test.altair.sanity.test_' + key for key in [
'blocks',
]}, **phase_0_mods}
merge_mods = {**{key: 'eth2spec.test.merge.sanity.test_' + key for key in [
]}
altair_mods = combine_mods(_new_altair_mods, phase_0_mods)
_new_merge_mods = {key: 'eth2spec.test.merge.sanity.test_' + key for key in [
'blocks',
]}, **altair_mods}
]}
merge_mods = combine_mods(_new_merge_mods, altair_mods)
all_mods = {
PHASE0: phase_0_mods,