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@01f496f4.

Generate fixtures for these test cases for Prague with:

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

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
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
def test_creating_delegation_designation_contract(
    state_test: StateTestFiller, pre: Alloc, create_opcode: Op
):
    """
    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 = 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(), salt=0),
        )
        + Op.STOP,
    )

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

    create_address = compute_create_address(
        address=contract_a, nonce=1, initcode=create_init, salt=0, 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

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) create_opcode
...fork_Prague-state_test-create_opcode_CREATE CREATE
...fork_Prague-state_test-create_opcode_CREATE2 CREATE2
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE CREATE
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE2 CREATE2
...fork_Osaka-state_test-create_opcode_CREATE CREATE
...fork_Osaka-state_test-create_opcode_CREATE2 CREATE2
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE CREATE
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE2 CREATE2