add a couple more sanity block tests for added rpoposer_index
This commit is contained in:
parent
757f5a31dd
commit
71be8940b6
|
@ -119,6 +119,49 @@ def test_invalid_block_sig(spec, state):
|
|||
yield 'post', None
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@spec_state_test
|
||||
@always_bls
|
||||
def test_invalid_proposer_index_sig_from_expected_proposer(spec, state):
|
||||
yield 'pre', state
|
||||
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
expect_proposer_index = block.proposer_index
|
||||
|
||||
# Set invalid proposer index but correct signature wrt expected proposer
|
||||
active_indices = spec.get_active_validator_indices(state, spec.get_current_epoch(state))
|
||||
active_indices = [i for i in active_indices if i != block.proposer_index]
|
||||
block.proposer_index = active_indices[0] # invalid proposer index
|
||||
|
||||
invalid_signed_block = sign_block(spec, state, block, expect_proposer_index)
|
||||
|
||||
expect_assertion_error(lambda: spec.state_transition(state, invalid_signed_block))
|
||||
|
||||
yield 'blocks', [invalid_signed_block]
|
||||
yield 'post', None
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@spec_state_test
|
||||
@always_bls
|
||||
def test_invalid_proposer_index_sig_from_proposer_index(spec, state):
|
||||
yield 'pre', state
|
||||
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
|
||||
# Set invalid proposer index but correct signature wrt proposer_index
|
||||
active_indices = spec.get_active_validator_indices(state, spec.get_current_epoch(state))
|
||||
active_indices = [i for i in active_indices if i != block.proposer_index]
|
||||
block.proposer_index = active_indices[0] # invalid proposer index
|
||||
|
||||
invalid_signed_block = sign_block(spec, state, block, block.proposer_index)
|
||||
|
||||
expect_assertion_error(lambda: spec.state_transition(state, invalid_signed_block))
|
||||
|
||||
yield 'blocks', [invalid_signed_block]
|
||||
yield 'post', None
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@spec_state_test
|
||||
def test_skipped_slots(spec, state):
|
||||
|
|
Loading…
Reference in New Issue