Skip to content

test_intrinsic_gas_floor_boundary_contract_creation()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_contract_creation@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_contract_creation --fork Amsterdam

Reject a contract-creation transaction when gas_limit = intrinsic_gas - 1.

A creation tx's intrinsic includes the NEW_ACCOUNT state gas, so the pre-execution check rejects against the combined regular + state intrinsic. The init code never runs.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "value",
    [
        pytest.param(0, id="zero_value"),
        pytest.param(1, id="non-zero_value"),
    ],
)
def test_intrinsic_gas_floor_boundary_contract_creation(
    fork: Fork,
    pre: Alloc,
    state_test: StateTestFiller,
    value: int,
) -> None:
    """
    Reject a contract-creation transaction when
    ``gas_limit = intrinsic_gas - 1``.

    A creation tx's intrinsic includes the ``NEW_ACCOUNT`` state gas, so
    the pre-execution check rejects against the combined
    ``regular + state`` intrinsic. The init code never runs.
    """
    sender = pre.fund_eoa(10**18)
    init_code = Op.STOP

    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
        calldata=init_code,
        contract_creation=True,
        sends_value=bool(value),
        return_cost_deducted_prior_execution=True,
    )

    tx = Transaction(
        sender=sender,
        to=None,
        value=value,
        data=init_code,
        gas_limit=intrinsic_gas - 1,
        gas_price=1_000_000_000,
        error=TransactionException.INTRINSIC_GAS_TOO_LOW,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.