test_max_stack()
Documentation for tests/frontier/opcodes/test_all_opcodes.py::test_max_stack@55d774b5.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/frontier/opcodes/test_all_opcodes.py::test_max_stack --fork Amsterdam
Test that opcodes that don't push more items than they pop from the
stack can operate when the stack is full.
Source code in tests/frontier/opcodes/test_all_opcodes.py
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273 | @pytest.mark.parametrize_by_fork(
"opcode", fork_opcodes_with_non_increasing_stack
)
def test_max_stack(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
opcode: Op,
env: Environment,
) -> None:
"""
Test that opcodes that don't push more items than they pop from the
stack can operate when the stack is full.
"""
pre_stack_items = fork.max_stack_height()
slot_code_worked = 1
value_code_failed = 0xDEADBEEF
value_code_worked = 1
push_opcode = Op.PUSH0 if Op.PUSH0 in fork.valid_opcodes() else Op.PUSH1(0)
contract = pre.deploy_contract(
code=Op.SSTORE(slot_code_worked, value_code_worked)
+ push_opcode * pre_stack_items
+ opcode
+ Op.STOP,
storage={slot_code_worked: value_code_failed},
)
gas_limit = 100_000
if fork.is_eip_enabled(8037):
gas_limit = 500_000
tx = Transaction(
gas_limit=gas_limit,
to=contract,
sender=pre.fund_eoa(),
protected=fork.supports_protected_txs(),
)
expected_storage = {slot_code_worked: value_code_worked}
state_test(
env=env,
pre=pre,
tx=tx,
post={contract: Account(storage=expected_storage)},
)
|
Parametrized Test Cases
This test generates 78 parametrized test cases across 14 forks.