mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 23:34:58 -05:00
Add test_ejection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user