Remove redundant keys and use Dict for `phase_0_mods`, `phase_1_mods` instead of List

This commit is contained in:
Hsiao-Wei Wang 2020-09-15 11:00:36 +08:00
parent 28137a6176
commit c0c2461d2f
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
4 changed files with 30 additions and 33 deletions

View File

@ -31,28 +31,28 @@ def create_provider(fork_name: str, handler_name: str, tests_src_mod_name: str,
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = [(key, 'eth2spec.test.phase0.epoch_processing.test_process_' + key) for key in [ phase_0_mods = {key: 'eth2spec.test.phase0.epoch_processing.test_process_' + key for key in [
'final_updates', 'final_updates',
'justification_and_finalization', 'justification_and_finalization',
'registry_updates', 'registry_updates',
'rewards_and_penalties', 'rewards_and_penalties',
'slashings', 'slashings',
]] ]}
phase_1_mods = [(key, 'eth2spec.test.phase1.epoch_processing.test_process_' + key) for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.epoch_processing.test_process_' + key for key in [
'challenge_deadlines', 'challenge_deadlines',
'custody_final_updates', 'custody_final_updates',
'reveal_deadlines', 'reveal_deadlines',
]] + phase_0_mods # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"epoch_processing", [ gen_runner.run_generator(f"epoch_processing", [
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"epoch_processing", [ gen_runner.run_generator(f"epoch_processing", [
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"epoch_processing", [ gen_runner.run_generator(f"epoch_processing", [
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items()
]) ])
gen_runner.run_generator(f"epoch_processing", [ gen_runner.run_generator(f"epoch_processing", [
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items()
]) ])

View File

@ -31,32 +31,32 @@ def create_provider(fork_name: str, handler_name: str, tests_src_mod_name: str,
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = [(key, 'eth2spec.test.phase0.block_processing.test_process_' + key) for key in [ phase_0_mods = {key: 'eth2spec.test.phase0.block_processing.test_process_' + key for key in [
'attestation', 'attestation',
'attester_slashing', 'attester_slashing',
'block_header', 'block_header',
'deposit', 'deposit',
'proposer_slashing', 'proposer_slashing',
'voluntary_exit', 'voluntary_exit',
]] ]}
phase_1_mods = [(key, 'eth2spec.test.phase1.block_processing.test_process_' + key) for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.block_processing.test_process_' + key for key in [
'attestation', 'attestation',
'chunk_challenge', 'chunk_challenge',
'custody_key_reveal', 'custody_key_reveal',
'custody_slashing', 'custody_slashing',
'early_derived_secret_reveal', 'early_derived_secret_reveal',
'shard_transition', 'shard_transition',
]] + phase_0_mods # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"operations", [ gen_runner.run_generator(f"operations", [
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"operations", [ gen_runner.run_generator(f"operations", [
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"operations", [ gen_runner.run_generator(f"operations", [
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items()
]) ])
gen_runner.run_generator(f"operations", [ gen_runner.run_generator(f"operations", [
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items()
]) ])

View File

@ -31,26 +31,23 @@ def create_provider(fork_name: str, handler_name: str, tests_src_mod_name: str,
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = [(key, 'eth2spec.test.phase0.rewards.test_'+key) for key in [ phase_0_mods = {key: 'eth2spec.test.phase0.rewards.test_'+key for key in [
'basic',
'basic', 'basic',
'leak', 'leak',
'leak',
'random', 'random',
'random', ]}
]]
# No additional phase 1 specific rewards tests, yet. # No additional phase 1 specific rewards tests, yet.
phase_1_mods = phase_0_mods phase_1_mods = phase_0_mods
gen_runner.run_generator(f"rewards", [ gen_runner.run_generator(f"rewards", [
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"rewards", [ gen_runner.run_generator(f"rewards", [
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"rewards", [ gen_runner.run_generator(f"rewards", [
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items()
]) ])
gen_runner.run_generator(f"rewards", [ gen_runner.run_generator(f"rewards", [
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items()
]) ])

View File

@ -31,24 +31,24 @@ def create_provider(fork_name: str, handler_name: str, tests_src_mod_name: str,
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = [(key, 'eth2spec.test.phase0.sanity.test_' + key) for key in [ phase_0_mods = {key: 'eth2spec.test.phase0.sanity.test_' + key for key in [
'blocks', 'blocks',
'slots', 'slots',
]] ]}
phase_1_mods = [(key, 'eth2spec.test.phase1.sanity.test_' + key) for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.sanity.test_' + key for key in [
'blocks', # more phase 1 specific block tests 'blocks', # more phase 1 specific block tests
'shard_blocks', 'shard_blocks',
]] + phase_0_mods # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"sanity", [ gen_runner.run_generator(f"sanity", [
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"sanity", [ gen_runner.run_generator(f"sanity", [
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items()
]) ])
gen_runner.run_generator(f"sanity", [ gen_runner.run_generator(f"sanity", [
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items()
]) ])
gen_runner.run_generator(f"sanity", [ gen_runner.run_generator(f"sanity", [
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items()
]) ])