diff --git a/test_libs/pyspec/tests/epoch_processing/test_process_registry_updates.py b/test_libs/pyspec/tests/epoch_processing/test_process_registry_updates.py index 9bc70335b..6a3f156c4 100644 --- a/test_libs/pyspec/tests/epoch_processing/test_process_registry_updates.py +++ b/test_libs/pyspec/tests/epoch_processing/test_process_registry_updates.py @@ -12,12 +12,13 @@ from tests.helpers import ( def test_activation(state): - # Mock a new deposit index = 0 + assert is_active_validator(state.validator_registry[index], get_current_epoch(state)) + + # Mock a new deposit state.validator_registry[index].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH state.validator_registry[index].activation_epoch = spec.FAR_FUTURE_EPOCH state.validator_registry[index].effective_balance = spec.MAX_EFFECTIVE_BALANCE - assert not is_active_validator(state.validator_registry[index], get_current_epoch(state)) pre_state = deepcopy(state) @@ -33,3 +34,25 @@ def test_activation(state): ) return pre_state, state + + +def test_ejection(state): + index = 0 + assert is_active_validator(state.validator_registry[index], get_current_epoch(state)) + assert state.validator_registry[index].exit_epoch == spec.FAR_FUTURE_EPOCH + + # Mock an ejection + state.validator_registry[index].effective_balance = spec.EJECTION_BALANCE + + pre_state = deepcopy(state) + + for _ in range(spec.ACTIVATION_EXIT_DELAY + 1): + next_epoch(state) + + assert state.validator_registry[index].exit_epoch != spec.FAR_FUTURE_EPOCH + assert not is_active_validator( + state.validator_registry[index], + get_current_epoch(state), + ) + + return pre_state, state