Skip to content

test_tx_gas_larger_than_block_gas_limit()

Documentation for tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_tx_gas_larger_than_block_gas_limit@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_tx_gas_larger_than_block_gas_limit --fork Osaka

Test multiple transactions with total gas larger than the block gas limit.

Source code in tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
@pytest.mark.parametrize(
    "exceed_block_gas_limit",
    [
        pytest.param(True, marks=pytest.mark.exception_test),
        pytest.param(False),
    ],
)
@pytest.mark.valid_from("Osaka")
def test_tx_gas_larger_than_block_gas_limit(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    env: Environment,
    fork: Fork,
    exceed_block_gas_limit: bool,
) -> None:
    """
    Test multiple transactions with total gas larger than the block gas limit.
    """
    tx_gas_limit_cap = fork.transaction_gas_limit_cap()
    assert tx_gas_limit_cap is not None, "Fork does not have a transaction gas limit cap"

    tx_count = env.gas_limit // tx_gas_limit_cap

    gas_spender_contract = pre.deploy_contract(code=Op.INVALID)
    block = Block(
        txs=[
            Transaction(
                to=gas_spender_contract,
                sender=pre.fund_eoa(),
                gas_limit=tx_gas_limit_cap,
                error=TransactionException.GAS_ALLOWANCE_EXCEEDED if i >= tx_count else None,
            )
            for i in range(tx_count + int(exceed_block_gas_limit))
        ],
        exception=TransactionException.GAS_ALLOWANCE_EXCEEDED if exceed_block_gas_limit else None,
    )

    blockchain_test(pre=pre, post={}, blocks=[block])

Parametrized Test Cases

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

Test ID (Abbreviated) exceed_block_gas_limit
...fork_Osaka-blockchain_test-exceed_block_gas_limit_True True
...fork_Osaka-blockchain_test-exceed_block_gas_limit_False False