voluntary exit test case: invalid index

This commit is contained in:
protolambda 2019-05-11 18:31:05 +02:00
parent 17d057e503
commit 636a45a415
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
1 changed files with 22 additions and 1 deletions

View File

@ -23,7 +23,6 @@ def run_voluntary_exit_processing(state, voluntary_exit, valid=True):
If ``valid == False``, run expecting ``AssertionError``
"""
validator_index = voluntary_exit.validator_index
pre_exit_epoch = state.validator_registry[validator_index].exit_epoch
yield 'pre', state
yield 'voluntary_exit', voluntary_exit
@ -33,6 +32,8 @@ def run_voluntary_exit_processing(state, voluntary_exit, valid=True):
yield 'post', None
return
pre_exit_epoch = state.validator_registry[validator_index].exit_epoch
process_voluntary_exit(state, voluntary_exit)
yield 'post', state
@ -107,6 +108,26 @@ def test_success_exit_queue(state):
)
@spec_state_test
def test_validator_invalid_validator_index(state):
# move state forward PERSISTENT_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.PERSISTENT_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = get_current_epoch(state)
validator_index = get_active_validator_indices(state, current_epoch)[0]
privkey = pubkey_to_privkey[state.validator_registry[validator_index].pubkey]
voluntary_exit = build_voluntary_exit(
state,
current_epoch,
validator_index,
privkey,
)
voluntary_exit.validator_index = len(state.validator_registry)
yield from run_voluntary_exit_processing(state, voluntary_exit, False)
@spec_state_test
def test_validator_not_active(state):
current_epoch = get_current_epoch(state)