mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-13 12:14:19 +00:00
add scaled churn limit tests for voluntary exits
This commit is contained in:
parent
43e79a7ee0
commit
6784025d64
@ -1,4 +1,9 @@
|
|||||||
from eth2spec.test.context import spec_state_test, expect_assertion_error, always_bls, with_all_phases
|
from eth2spec.test.context import (
|
||||||
|
spec_state_test, expect_assertion_error,
|
||||||
|
always_bls, with_all_phases,
|
||||||
|
spec_test, single_phase,
|
||||||
|
with_custom_state, scaled_churn_balances,
|
||||||
|
)
|
||||||
from eth2spec.test.helpers.keys import pubkey_to_privkey
|
from eth2spec.test.helpers.keys import pubkey_to_privkey
|
||||||
from eth2spec.test.helpers.voluntary_exits import sign_voluntary_exit
|
from eth2spec.test.helpers.voluntary_exits import sign_voluntary_exit
|
||||||
|
|
||||||
@ -68,9 +73,7 @@ def test_invalid_signature(spec, state):
|
|||||||
yield from run_voluntary_exit_processing(spec, state, signed_voluntary_exit, False)
|
yield from run_voluntary_exit_processing(spec, state, signed_voluntary_exit, False)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
def run_test_success_exit_queue(spec, state):
|
||||||
@spec_state_test
|
|
||||||
def test_success_exit_queue(spec, state):
|
|
||||||
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
|
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
|
||||||
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
|
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
|
||||||
|
|
||||||
@ -106,12 +109,29 @@ def test_success_exit_queue(spec, state):
|
|||||||
# when processing an additional exit, it results in an exit in a later epoch
|
# when processing an additional exit, it results in an exit in a later epoch
|
||||||
yield from run_voluntary_exit_processing(spec, state, signed_voluntary_exit)
|
yield from run_voluntary_exit_processing(spec, state, signed_voluntary_exit)
|
||||||
|
|
||||||
|
for index in initial_indices:
|
||||||
assert (
|
assert (
|
||||||
state.validators[validator_index].exit_epoch ==
|
state.validators[validator_index].exit_epoch ==
|
||||||
state.validators[initial_indices[0]].exit_epoch + 1
|
state.validators[index].exit_epoch + 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@with_all_phases
|
||||||
|
@spec_state_test
|
||||||
|
def test_success_exit_queue__min_churn(spec, state):
|
||||||
|
yield from run_test_success_exit_queue(spec, state)
|
||||||
|
|
||||||
|
|
||||||
|
@with_all_phases
|
||||||
|
@spec_test
|
||||||
|
@with_custom_state(balances_fn=scaled_churn_balances, threshold_fn=lambda spec: spec.config.EJECTION_BALANCE)
|
||||||
|
@single_phase
|
||||||
|
def test_success_exit_queue__scaled_churn(spec, state):
|
||||||
|
churn_limit = spec.get_validator_churn_limit(state)
|
||||||
|
assert churn_limit > spec.config.MIN_PER_EPOCH_CHURN_LIMIT
|
||||||
|
yield from run_test_success_exit_queue(spec, state)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_default_exit_epoch_subsequent_exit(spec, state):
|
def test_default_exit_epoch_subsequent_exit(spec, state):
|
||||||
|
@ -302,7 +302,7 @@ def test_activation_queue_activation_and_ejection__1(spec, state):
|
|||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_activation_queue_activation_and_ejection__churn_limit(spec, state):
|
def test_activation_queue_activation_and_ejection__churn_limit(spec, state):
|
||||||
num_validators_per_status= spec.get_validator_churn_limit(state)
|
num_validators_per_status = spec.get_validator_churn_limit(state)
|
||||||
yield from run_test_activation_queue_activation_and_ejection(spec, state, num_validators_per_status)
|
yield from run_test_activation_queue_activation_and_ejection(spec, state, num_validators_per_status)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user