Skip to content

test_deploying_delegation_designation_contract()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_deploying_delegation_designation_contract@20373115.

Generate fixtures for these test cases for Amsterdam with:

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

Test attempting to deploy a contract that has the same format as a delegation designation.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3913
3914
3915
3916
3917
3918
3919
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
@pytest.mark.parametrize(
    "initcode_is_delegation_designation",
    [
        pytest.param(True, id="initcode_deploys_delegation_designation"),
        pytest.param(False, id="initcode_is_delegation_designation"),
    ],
)
def test_deploying_delegation_designation_contract(
    state_test: StateTestFiller,
    pre: Alloc,
    initcode_is_delegation_designation: bool,
) -> None:
    """
    Test attempting to deploy a contract that has the same format as a
    delegation designation.
    """
    sender = pre.fund_eoa()

    set_to_code = Op.RETURN(0, 1)
    set_to_address = pre.deploy_contract(set_to_code)

    initcode: Bytes | Bytecode
    if initcode_is_delegation_designation:
        initcode = Spec.delegation_designation(set_to_address)
    else:
        initcode = Initcode(
            deploy_code=Spec.delegation_designation(set_to_address)
        )

    tx = Transaction(
        sender=sender,
        to=None,
        gas_limit=100_000,
        data=initcode,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            sender: Account(
                nonce=1,
            ),
            tx.created_contract: Account.NONEXISTENT,
        },
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 3 forks.