diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py index 2ccecec1a..25a76a686 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py @@ -39,7 +39,7 @@ def test_transition_with_one_fourth_exiting_validators_exit_post_fork(state, rng=random.Random(5566), fraction=0.25, exit_epoch=10, - forward=False, + from_epoch=spec.get_current_epoch(state), ) transition_until_fork(spec, state, fork_epoch) @@ -97,7 +97,7 @@ def test_transition_with_one_fourth_exiting_validators_exit_at_fork(state, rng=random.Random(5566), fraction=0.25, exit_epoch=fork_epoch, - forward=False, + from_epoch=spec.get_current_epoch(state), ) transition_until_fork(spec, state, fork_epoch) diff --git a/tests/core/pyspec/eth2spec/test/helpers/random.py b/tests/core/pyspec/eth2spec/test/helpers/random.py index 4f6139989..1332d1e90 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/random.py +++ b/tests/core/pyspec/eth2spec/test/helpers/random.py @@ -25,17 +25,18 @@ def set_some_new_deposits(spec, state, rng): return deposited_indices -def exit_random_validators(spec, state, rng, fraction=0.5, exit_epoch=None, withdrawable_epoch=None, forward=True): +def exit_random_validators(spec, state, rng, fraction=0.5, exit_epoch=None, withdrawable_epoch=None, from_epoch=None): """ Set some validators' exit_epoch and withdrawable_epoch. If exit_epoch is configured, use the given exit_epoch. Otherwise, randomly set exit_epoch and withdrawable_epoch. """ - if forward: - if spec.get_current_epoch(state) < 5: - # Move epochs forward to allow for some validators already exited/withdrawable - for _ in range(5): - next_epoch(spec, state) + if from_epoch is None: + from_epoch = spec.MAX_SEED_LOOKAHEAD + 1 + epoch_diff = from_epoch - spec.get_current_epoch(state) + for _ in range(epoch_diff): + # NOTE: if `epoch_diff` is negative, then this loop body does not execute. + next_epoch(spec, state) current_epoch = spec.get_current_epoch(state) exited_indices = []