add invalid test for BLSChange genesis_validators_root

This commit is contained in:
djrtwo
2023-01-13 08:07:21 -07:00
parent 6a19cf568a
commit d4eaf4bff4
2 changed files with 20 additions and 3 deletions

View File

@@ -199,3 +199,12 @@ def test_invalid_previous_fork_version(spec, state):
signed_address_change = get_signed_address_change(spec, state, fork_version=state.fork.previous_version)
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=False)
@with_capella_and_later
@spec_state_test
@always_bls
def test_invalid_genesis_validators_root(spec, state):
signed_address_change = get_signed_address_change(spec, state, genesis_validators_root=b'\x99' * 32)
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=False)

View File

@@ -2,8 +2,12 @@ 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, to_execution_address=None,
fork_version=None):
def get_signed_address_change(spec, state,
validator_index=None,
withdrawal_pubkey=None,
to_execution_address=None,
fork_version=None,
genesis_validators_root=None):
if validator_index is None:
validator_index = 0
@@ -17,10 +21,14 @@ def get_signed_address_change(spec, state, validator_index=None, withdrawal_pubk
if to_execution_address is None:
to_execution_address = b'\x42' * 20
if genesis_validators_root is None:
genesis_validators_root = spec.genesis_validators_root
domain = spec.compute_domain(
spec.DOMAIN_BLS_TO_EXECUTION_CHANGE,
fork_version=fork_version,
genesis_validators_root=state.genesis_validators_root)
genesis_validators_root=genesis_validators_root,
)
address_change = spec.BLSToExecutionChange(
validator_index=validator_index,