add a few more proposer slashing tests

This commit is contained in:
Danny Ryan 2020-09-10 16:50:03 -06:00
parent e5f110a37b
commit 1785f987f8
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A

View File

@ -79,6 +79,20 @@ def test_invalid_sig_1_and_2(spec, state):
yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False) yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False)
@with_all_phases
@spec_state_test
@always_bls
def test_invalid_sig_1_and_2_swap(spec, state):
# Get valid signatures for the slashings
proposer_slashing = get_valid_proposer_slashing(spec, state, signed_1=True, signed_2=True)
# But swap them
signature_1 = proposer_slashing.signed_header_1.signature
proposer_slashing.signed_header_1.signature = proposer_slashing.signed_header_2.signature
proposer_slashing.signed_header_2.signature = signature_1
yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False)
@with_all_phases @with_all_phases
@spec_state_test @spec_state_test
def test_invalid_proposer_index(spec, state): def test_invalid_proposer_index(spec, state):
@ -122,11 +136,26 @@ def test_epochs_are_different(spec, state):
@with_all_phases @with_all_phases
@spec_state_test @spec_state_test
def test_headers_are_same(spec, state): def test_headers_are_same_sigs_are_same(spec, state):
proposer_slashing = get_valid_proposer_slashing(spec, state, signed_1=True, signed_2=False) proposer_slashing = get_valid_proposer_slashing(spec, state, signed_1=True, signed_2=False)
# set headers to be the same # set headers to be the same
proposer_slashing.signed_header_2 = proposer_slashing.signed_header_1 proposer_slashing.signed_header_2 = proposer_slashing.signed_header_1.copy()
yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False)
@with_all_phases
@spec_state_test
def test_headers_are_same_sigs_are_different(spec, state):
proposer_slashing = get_valid_proposer_slashing(spec, state, signed_1=True, signed_2=False)
# set headers to be the same
proposer_slashing.signed_header_2 = proposer_slashing.signed_header_1.copy()
# but signatures to be different
proposer_slashing.signed_header_2.signature = proposer_slashing.signed_header_2.signature[:-1] + b'\x00'
assert proposer_slashing.signed_header_1.signature != proposer_slashing.signed_header_2.signature
yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False) yield from run_proposer_slashing_processing(spec, state, proposer_slashing, False)