Skip to content

test_set_code_using_chain_specific_id()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_using_chain_specific_id@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_using_chain_specific_id --fork Bogota

Test sending a transaction to set the code of an account using a chain-specific ID.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
@pytest.mark.bigmem
@pytest.mark.xdist_group(name="bigmem")
def test_set_code_using_chain_specific_id(
    state_test: StateTestFiller,
    pre: Alloc,
    chain_config: ChainConfig,
) -> None:
    """
    Test sending a transaction to set the code of an account using a
    chain-specific ID.
    """
    auth_signer = pre.fund_eoa(auth_account_start_balance)

    success_slot = 1

    set_code = Op.SSTORE(success_slot, 1) + Op.STOP
    set_code_to_address = pre.deploy_contract(set_code)

    tx = Transaction(
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=0,
                chain_id=chain_config.chain_id,
                signer=auth_signer,
            )
        ],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address),
                storage={
                    success_slot: 1,
                },
            ),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 4 forks.