Skip to content

test_blobbasefee_out_of_gas()

Documentation for tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py::test_blobbasefee_out_of_gas@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py::test_blobbasefee_out_of_gas --fork Amsterdam

Tests that the BLOBBASEFEE opcode fails with insufficient gas.

Source code in tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
@pytest.mark.parametrize(
    "call_fails",
    [
        pytest.param(False, id="enough_gas"),
        pytest.param(True, id="out_of_gas"),
    ],
)
@pytest.mark.valid_from("Cancun")
def test_blobbasefee_out_of_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    call_fails: bool,
) -> None:
    """Tests that the BLOBBASEFEE opcode fails with insufficient gas."""
    blobbasefee_gas = Op.BLOBBASEFEE.gas_cost(fork)
    call_gas = blobbasefee_gas - 1 if call_fails else blobbasefee_gas

    callee_code = Op.BLOBBASEFEE + Op.STOP
    callee_address = pre.deploy_contract(callee_code)

    caller_code = Op.SSTORE(
        Op.SELFBALANCE,
        Op.CALL(gas=call_gas, address=callee_address),
    )
    caller_address = pre.deploy_contract(caller_code)

    tx = Transaction(
        sender=pre.fund_eoa(),
        to=caller_address,
        value=1,
    )

    post = {
        caller_address: Account(
            storage={1: 0 if call_fails else 1},
        ),
        callee_address: Account(
            balance=0,
        ),
    }
    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 2 parametrized test cases across 4 forks.