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@49a16fac.

Generate fixtures for these test cases for Prague with:

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

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
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
def test_set_code_using_chain_specific_id(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """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(
        gas_limit=100_000,
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=0,
                chain_id=1,
                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 case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-blockchain_test
...fork_Prague-state_test
...fork_Osaka-blockchain_test
...fork_Osaka-state_test