Add `test_invalid_two_bls_changes_of_different_addresses_same_validator_same_block`
This commit is contained in:
parent
b78bd1fae0
commit
9f4adfde9d
|
@ -79,7 +79,7 @@ def test_success_exit_and_bls_change(spec, state):
|
|||
|
||||
@with_phases([CAPELLA])
|
||||
@spec_state_test
|
||||
def test_fail_double_bls_changes_same_block(spec, state):
|
||||
def test_invalid_double_bls_changes_same_block(spec, state):
|
||||
index = 0
|
||||
signed_address_change = get_signed_address_change(spec, state, validator_index=index)
|
||||
yield 'pre', state
|
||||
|
@ -96,6 +96,30 @@ def test_fail_double_bls_changes_same_block(spec, state):
|
|||
yield 'post', None
|
||||
|
||||
|
||||
@with_phases([CAPELLA])
|
||||
@spec_state_test
|
||||
def test_invalid_two_bls_changes_of_different_addresses_same_validator_same_block(spec, state):
|
||||
index = 0
|
||||
|
||||
signed_address_change_1 = get_signed_address_change(spec, state, validator_index=index,
|
||||
to_execution_address=b'\x12' * 20)
|
||||
signed_address_change_2 = get_signed_address_change(spec, state, validator_index=index,
|
||||
to_execution_address=b'\x34' * 20)
|
||||
assert signed_address_change_1 != signed_address_change_2
|
||||
|
||||
yield 'pre', state
|
||||
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
|
||||
block.body.bls_to_execution_changes.append(signed_address_change_1)
|
||||
block.body.bls_to_execution_changes.append(signed_address_change_2)
|
||||
|
||||
signed_block = state_transition_and_sign_block(spec, state, block, expect_fail=True)
|
||||
|
||||
yield 'blocks', [signed_block]
|
||||
yield 'post', None
|
||||
|
||||
|
||||
#
|
||||
# Withdrawals
|
||||
#
|
||||
|
|
|
@ -2,7 +2,7 @@ from eth2spec.utils import bls
|
|||
from eth2spec.test.helpers.keys import pubkeys, privkeys, pubkey_to_privkey
|
||||
|
||||
|
||||
def get_signed_address_change(spec, state, validator_index=None, withdrawal_pubkey=None):
|
||||
def get_signed_address_change(spec, state, validator_index=None, withdrawal_pubkey=None, to_execution_address=None):
|
||||
if validator_index is None:
|
||||
validator_index = 0
|
||||
|
||||
|
@ -13,11 +13,14 @@ def get_signed_address_change(spec, state, validator_index=None, withdrawal_pubk
|
|||
else:
|
||||
withdrawal_privkey = pubkey_to_privkey[withdrawal_pubkey]
|
||||
|
||||
if to_execution_address is None:
|
||||
to_execution_address = b'\x42' * 20
|
||||
|
||||
domain = spec.get_domain(state, spec.DOMAIN_BLS_TO_EXECUTION_CHANGE)
|
||||
address_change = spec.BLSToExecutionChange(
|
||||
validator_index=validator_index,
|
||||
from_bls_pubkey=withdrawal_pubkey,
|
||||
to_execution_address=b'\x42' * 20,
|
||||
to_execution_address=to_execution_address,
|
||||
)
|
||||
|
||||
signing_root = spec.compute_signing_root(address_change, domain)
|
||||
|
|
Loading…
Reference in New Issue