Skip to content

Commit

Permalink
Make from -> to bounds explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status committed Nov 28, 2024
1 parent a52a82c commit 09e8f01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions tests/core/pyspec/eth2spec/test/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 09e8f01

Please sign in to comment.