Skip to content

test_creating_delegation_designation_contract()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_creating_delegation_designation_contract@26332146.

Generate fixtures for these test cases for Amsterdam with:

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

Tx -> create -> pointer bytecode.

Attempt to deploy contract with magic bytes result in no contract being created.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
@pytest.mark.parametrize(
    "initcode_is_delegation_designation",
    [
        pytest.param(True, id="initcode_deploys_delegation_designation"),
        pytest.param(False, id="initcode_is_delegation_designation"),
    ],
)
@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
def test_creating_delegation_designation_contract(
    state_test: StateTestFiller,
    pre: Alloc,
    create_opcode: Op,
    initcode_is_delegation_designation: bool,
) -> None:
    """
    Tx -> create -> pointer bytecode.

    Attempt to deploy contract with magic bytes result in no
    contract being created.
    """
    env = Environment()

    storage: Storage = Storage()

    sender = pre.fund_eoa()

    # An attempt to deploy code starting with ef01 result in no
    # contract being created as it is prohibited

    create_init: Bytes | Bytecode
    if initcode_is_delegation_designation:
        create_init = Spec.delegation_designation(sender)
    else:
        create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
    contract_a = pre.deploy_contract(
        balance=100,
        code=Op.MSTORE(0, Op.CALLDATALOAD(0))
        + Op.SSTORE(
            storage.store_next(0, "contract_a_create_result"),
            create_opcode(value=1, offset=0, size=Op.CALLDATASIZE()),
        )
        + Op.STOP,
    )

    tx = Transaction(
        to=contract_a,
        data=create_init,
        value=0,
        sender=sender,
    )

    create_address = compute_create_address(
        address=contract_a, nonce=1, initcode=create_init, opcode=create_opcode
    )
    post = {
        contract_a: Account(balance=100, storage=storage),
        create_address: Account.NONEXISTENT,
    }
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.