Skip to content

test_create_tx_intrinsic_gas_boundary()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_tx_intrinsic_gas_boundary@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_tx_intrinsic_gas_boundary --fork Amsterdam

Test CREATE tx intrinsic gas boundary includes state component.

The intrinsic gas for a contract-creating transaction includes both regular gas and state gas. A transaction with gas_limit exactly at the boundary succeeds; one gas below is rejected.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
@pytest.mark.parametrize(
    "gas_delta",
    [
        pytest.param(
            -1,
            id="below_intrinsic",
            marks=pytest.mark.exception_test,
        ),
        pytest.param(0, id="at_intrinsic"),
    ],
)
@pytest.mark.valid_from("EIP8037")
def test_create_tx_intrinsic_gas_boundary(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    gas_delta: int,
) -> None:
    """
    Test CREATE tx intrinsic gas boundary includes state component.

    The intrinsic gas for a contract-creating transaction includes
    both regular gas and state gas. A transaction with gas_limit
    exactly at the boundary succeeds; one gas below is rejected.
    """
    intrinsic_cost = fork.transaction_intrinsic_cost_calculator()
    gas_limit = intrinsic_cost(
        contract_creation=True,
    )

    tx = Transaction(
        to=None,
        gas_limit=gas_limit + gas_delta,
        sender=pre.fund_eoa(),
        error=(
            TransactionException.INTRINSIC_GAS_TOO_LOW
            if gas_delta < 0
            else None
        ),
    )

    state_test(pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.