Skip to content

test_eofcreate_insufficient_stipend()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_eofcreate_insufficient_stipend@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_eofcreate_insufficient_stipend --fork Osaka

Exercises an EOFCREATE that fails because the calling account does not have enough ether to pay the stipend.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
@pytest.mark.parametrize(
    "value",
    [
        pytest.param(1, id="1_wei"),
        pytest.param(10**9, id="1_gwei"),
    ],
)
def test_eofcreate_insufficient_stipend(
    state_test: StateTestFiller,
    pre: Alloc,
    value: int,
):
    """
    Exercises an EOFCREATE that fails because the calling account does not have enough ether to
    pay the stipend.
    """
    env = Environment()
    initcode_container = Container(
        sections=[
            Section.Code(
                code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](value, 0, 0, 0))
                + Op.SSTORE(slot_code_worked, value_code_worked)
                + Op.STOP,
            ),
            Section.Container(container=smallest_initcode_subcontainer),
        ]
    )
    sender = pre.fund_eoa(10**11)
    contract_address = pre.deploy_contract(
        code=initcode_container,
        balance=value - 1,
    )
    # create will fail but not trigger a halt, so canary at storage 1 should be set
    # also validate target created contract fails
    post = {
        contract_address: Account(
            storage={
                slot_create_address: EOFCREATE_FAILURE,
                slot_code_worked: value_code_worked,
            }
        ),
        compute_eofcreate_address(contract_address, 0, initcode_container): Account.NONEXISTENT,
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
    )
    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) value
...fork_Osaka-state_test-1_wei 1
...fork_Osaka-state_test-1_gwei 1000000000
...fork_Osaka-blockchain_test_from_state_test-1_wei 1
...fork_Osaka-blockchain_test_from_state_test-1_gwei 1000000000