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@343274cc.

Generate fixtures for these test cases for Amsterdam with:

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

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
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
@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 3 forks.