new proposer slashing tests
Co-Authored-By: jannikluhn <jannik@brainbot.com>
This commit is contained in:
parent
8570584a95
commit
3189cf0079
|
@ -19,7 +19,6 @@ def run_proposer_slashing_processing(state, proposer_slashing, valid=True):
|
|||
- post-state ('post').
|
||||
If ``valid == False``, run expecting ``AssertionError``
|
||||
"""
|
||||
pre_proposer_balance = get_balance(state, proposer_slashing.proposer_index)
|
||||
|
||||
yield 'pre', state
|
||||
yield 'proposer_slashing', proposer_slashing
|
||||
|
@ -29,6 +28,8 @@ def run_proposer_slashing_processing(state, proposer_slashing, valid=True):
|
|||
yield 'post', None
|
||||
return
|
||||
|
||||
pre_proposer_balance = get_balance(state, proposer_slashing.proposer_index)
|
||||
|
||||
process_proposer_slashing(state, proposer_slashing)
|
||||
yield 'post', state
|
||||
|
||||
|
@ -52,6 +53,15 @@ def test_success(state):
|
|||
yield from run_proposer_slashing_processing(state, proposer_slashing)
|
||||
|
||||
|
||||
@spec_state_test
|
||||
def test_invalid_proposer_index(state):
|
||||
proposer_slashing = get_valid_proposer_slashing(state)
|
||||
# Index just too high (by 1)
|
||||
proposer_slashing.proposer_index = len(state.validator_registry)
|
||||
|
||||
yield from run_proposer_slashing_processing(state, proposer_slashing, False)
|
||||
|
||||
|
||||
@spec_state_test
|
||||
def test_epochs_are_different(state):
|
||||
proposer_slashing = get_valid_proposer_slashing(state)
|
||||
|
@ -72,6 +82,16 @@ def test_headers_are_same(state):
|
|||
yield from run_proposer_slashing_processing(state, proposer_slashing, False)
|
||||
|
||||
|
||||
@spec_state_test
|
||||
def test_proposer_is_not_activated(state):
|
||||
proposer_slashing = get_valid_proposer_slashing(state)
|
||||
|
||||
# set proposer to be not active yet
|
||||
state.validator_registry[proposer_slashing.proposer_index].activation_epoch = get_current_epoch(state) + 1
|
||||
|
||||
yield from run_proposer_slashing_processing(state, proposer_slashing, False)
|
||||
|
||||
|
||||
@spec_state_test
|
||||
def test_proposer_is_slashed(state):
|
||||
proposer_slashing = get_valid_proposer_slashing(state)
|
||||
|
|
|
@ -19,3 +19,6 @@ def expect_assertion_error(fn):
|
|||
raise AssertionError('expected an assertion error, but got none.')
|
||||
except AssertionError:
|
||||
pass
|
||||
except IndexError:
|
||||
# Index errors are special; the spec is not explicit on bound checking, an IndexError is like a failed assert.
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue