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@ffe48572.

Generate fixtures for these test cases for Bogota with:

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

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
@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,
        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 4 forks.