From 09e8f013105e40f487bfbd060f2a5732d9fd1ebe Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 28 Nov 2024 15:17:00 +0100 Subject: [PATCH] Make `from` -> `to` bounds explicit --- .../eth2spec/test/altair/light_client/test_sync.py | 10 +++++----- tests/core/pyspec/eth2spec/test/context.py | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py b/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py index 1c77e648ab..15437f0959 100644 --- a/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py +++ b/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py @@ -1,7 +1,7 @@ from eth2spec.test.context import ( spec_state_test_with_matching_config, spec_test, - with_all_phases_to, + with_all_phases_from_to, with_light_client, with_matching_spec_config, with_presets, @@ -12,7 +12,7 @@ state_transition_with_full_block, ) from eth2spec.test.helpers.constants import ( - CAPELLA, DENEB, ELECTRA, + ALTAIR, CAPELLA, DENEB, ELECTRA, MINIMAL, ) from eth2spec.test.helpers.light_client import ( @@ -381,7 +381,7 @@ def run_lc_sync_test_upgraded_store_with_legacy_data(spec, phases, state, fork): yield from finish_lc_sync_test(test) -@with_all_phases_to(CAPELLA, other_phases=[CAPELLA]) +@with_all_phases_from_to(ALTAIR, CAPELLA, other_phases=[CAPELLA]) @spec_test @with_state @with_matching_spec_config(emitted_fork=CAPELLA) @@ -390,7 +390,7 @@ def test_capella_store_with_legacy_data(spec, phases, state): yield from run_lc_sync_test_upgraded_store_with_legacy_data(spec, phases, state, CAPELLA) -@with_all_phases_to(DENEB, other_phases=[CAPELLA, DENEB]) +@with_all_phases_from_to(ALTAIR, DENEB, other_phases=[CAPELLA, DENEB]) @spec_test @with_state @with_matching_spec_config(emitted_fork=DENEB) @@ -399,7 +399,7 @@ def test_deneb_store_with_legacy_data(spec, phases, state): yield from run_lc_sync_test_upgraded_store_with_legacy_data(spec, phases, state, DENEB) -@with_all_phases_to(ELECTRA, other_phases=[CAPELLA, DENEB, ELECTRA]) +@with_all_phases_from_to(ALTAIR, ELECTRA, other_phases=[CAPELLA, DENEB, ELECTRA]) @spec_test @with_state @with_matching_spec_config(emitted_fork=ELECTRA) diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 16149bb861..a90190287d 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -436,13 +436,17 @@ def with_all_phases_from_except(earliest_phase, except_phases=None): return with_all_phases_from(earliest_phase, [phase for phase in ALL_PHASES if phase not in except_phases]) -def with_all_phases_to(next_phase, other_phases=None, all_phases=ALL_PHASES): +def with_all_phases_from_to(from_phase, to_phase, other_phases=None, all_phases=ALL_PHASES): """ - A decorator factory for running a tests with every phase up to and excluding the one listed + A decorator factory for running a tests with every phase + from a given start phase up to and excluding a given end phase """ def decorator(fn): return with_phases( - [phase for phase in all_phases if is_post_fork(next_phase, phase)], + [phase for phase in all_phases if ( + phase != to_phase and is_post_fork(to_phase, phase) + and is_post_fork(phase, from_phase) + )], other_phases=other_phases, )(fn) return decorator