From 1f3e73703c10c5e9c8c3dc182632a535222a8d7f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 10 Mar 2021 12:38:30 -0700 Subject: [PATCH] use 'other_phases' for fork tests --- tests/core/pyspec/eth2spec/test/context.py | 11 +++++++---- .../test/lightclient_patch/fork/test_fork.py | 14 +++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 1272485de..e197124c0 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -340,7 +340,7 @@ def with_phases(phases, other_phases=None): available_phases = set(run_phases) if other_phases is not None: - available_phases += set(other_phases) + available_phases |= set(other_phases) # TODO: test state is dependent on phase0 but is immediately transitioned to phase1. # A new state-creation helper for phase 1 may be in place, and then phase1+ tests can run without phase0 @@ -348,9 +348,12 @@ def with_phases(phases, other_phases=None): # Populate all phases for multi-phase tests phase_dir = {} - phase_dir[PHASE0] = spec_phase0 - phase_dir[PHASE1] = spec_phase1 - phase_dir[LIGHTCLIENT_PATCH] = spec_lightclient_patch + if PHASE0 in available_phases: + phase_dir[PHASE0] = spec_phase0 + if PHASE1 in available_phases: + phase_dir[PHASE1] = spec_phase1 + if LIGHTCLIENT_PATCH in available_phases: + phase_dir[LIGHTCLIENT_PATCH] = spec_lightclient_patch # return is ignored whenever multiple phases are ran. If if PHASE0 in run_phases: diff --git a/tests/core/pyspec/eth2spec/test/lightclient_patch/fork/test_fork.py b/tests/core/pyspec/eth2spec/test/lightclient_patch/fork/test_fork.py index dada24af9..27d181510 100644 --- a/tests/core/pyspec/eth2spec/test/lightclient_patch/fork/test_fork.py +++ b/tests/core/pyspec/eth2spec/test/lightclient_patch/fork/test_fork.py @@ -53,7 +53,7 @@ def run_fork_test(post_spec, pre_state): yield 'post', post_state -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @spec_test @with_state @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -61,7 +61,7 @@ def test_fork_base_state(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @spec_test @with_state @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -70,7 +70,7 @@ def test_fork_next_epoch(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @spec_test @with_state @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -79,7 +79,7 @@ def test_fork_next_epoch_with_block(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @spec_test @with_state @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -89,7 +89,7 @@ def test_fork_many_next_epoch(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @spec_test @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -97,7 +97,7 @@ def test_fork_random_low_balances(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @spec_test @with_meta_tags(HF1_FORK_TEST_META_TAGS) @@ -105,7 +105,7 @@ def test_fork_random_misc_balances(spec, phases, state): yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) -@with_phases(([PHASE0])) +@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH]) @with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @spec_test @with_meta_tags(HF1_FORK_TEST_META_TAGS)