From 6c6ed3eab9e3794f1f7f6c3f2e4daba229c3458f Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 9 Jan 2024 15:49:45 +0100 Subject: [PATCH] Extract sync committee period <-> slot helpers to common LC test module The two functions `compute_start_slot_at_sync_committee_period` and `compute_start_slot_at_next_sync_committee_period` are currently only available during LC `test_sync`. Move them to the common LC test module so that they can be used from future tests as well. --- .../eth2spec/test/altair/light_client/test_sync.py | 10 +--------- .../core/pyspec/eth2spec/test/helpers/light_client.py | 9 +++++++++ 2 files changed, 10 insertions(+), 9 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 f8faa2fdd..3ec995ca6 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 @@ -28,6 +28,7 @@ from eth2spec.test.helpers.forks import ( is_post_fork, ) from eth2spec.test.helpers.light_client import ( + compute_start_slot_at_next_sync_committee_period, get_sync_aggregate, ) from eth2spec.test.helpers.state import ( @@ -281,15 +282,6 @@ def emit_upgrade_store(test, new_s_spec, phases=None): }) -def compute_start_slot_at_sync_committee_period(spec, sync_committee_period): - return spec.compute_start_slot_at_epoch(sync_committee_period * spec.EPOCHS_PER_SYNC_COMMITTEE_PERIOD) - - -def compute_start_slot_at_next_sync_committee_period(spec, state): - sync_committee_period = spec.compute_sync_committee_period_at_slot(state.slot) - return compute_start_slot_at_sync_committee_period(spec, sync_committee_period + 1) - - @with_light_client @spec_state_test_with_matching_config @with_presets([MINIMAL], reason="too slow") diff --git a/tests/core/pyspec/eth2spec/test/helpers/light_client.py b/tests/core/pyspec/eth2spec/test/helpers/light_client.py index 1878832c3..15889843c 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/light_client.py +++ b/tests/core/pyspec/eth2spec/test/helpers/light_client.py @@ -8,6 +8,15 @@ from eth2spec.test.helpers.sync_committee import ( from math import floor +def compute_start_slot_at_sync_committee_period(spec, sync_committee_period): + return spec.compute_start_slot_at_epoch(sync_committee_period * spec.EPOCHS_PER_SYNC_COMMITTEE_PERIOD) + + +def compute_start_slot_at_next_sync_committee_period(spec, state): + sync_committee_period = spec.compute_sync_committee_period_at_slot(state.slot) + return compute_start_slot_at_sync_committee_period(spec, sync_committee_period + 1) + + def get_sync_aggregate(spec, state, num_participants=None, signature_slot=None): # By default, the sync committee signs the previous slot if signature_slot is None: