test_call_large_args_offset_size_zero()
Documentation for tests/frontier/opcodes/test_call.py::test_call_large_args_offset_size_zero@9c2813ee.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/frontier/opcodes/test_call.py::test_call_large_args_offset_size_zero --fork Amsterdam
Test xCALL with an extremely large args_offset and args_size set to zero.
Since the size is zero, the large offset should not cause a revert.
Source code in tests/frontier/opcodes/test_call.py
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
210
211
212
213
214
215
216
217
218
219
220
221
222 | @pytest.mark.with_all_call_opcodes
@pytest.mark.valid_from("Berlin")
def test_call_large_args_offset_size_zero(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
call_opcode: Op,
) -> None:
"""
Test xCALL with an extremely large args_offset and args_size set to zero.
Since the size is zero, the large offset should not cause a revert.
"""
sender = pre.fund_eoa()
very_large_offset = 2**100
# Cost of pushing args onto the stack (each PUSH costs VERY_LOW)
push_cost = (Op.PUSH1(0) * len(call_opcode.kwargs)).gas_cost(fork)
call_measure = CodeGasMeasure(
code=call_opcode(gas=0, args_offset=very_large_offset, args_size=0),
overhead_cost=push_cost,
extra_stack_items=1, # Because xCALL pushes 1 item to the stack
sstore_key=0,
)
contract = pre.deploy_contract(call_measure)
tx = Transaction(
gas_limit=500_000,
to=contract,
value=0,
sender=sender,
)
# this call cost is just the address_access_cost
call_cost = call_opcode(address_warm=False).gas_cost(fork)
state_test(
env=Environment(),
pre=pre,
tx=tx,
post={
contract: Account(
storage={
0: call_cost,
},
)
},
)
|
Parametrized Test Cases
This test generates 4 parametrized test cases across 8 forks.