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@26332146.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_tx_gas_larger_than_block_gas_limit --fork Amsterdam
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254 | @pytest.mark.inclusion_test
@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
This test generates 2 parametrized test cases across 2 forks.