Skip to content

test_eof_functions_contract_call_within_deep_nested()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_execution_function.py::test_eof_functions_contract_call_within_deep_nested@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_execution_function.py::test_eof_functions_contract_call_within_deep_nested --fork Osaka

Test performing a call within a nested callf and verify correct behavior of return stack in calling contract.

TODO: This test belongs in EIP-7069 test folder, not code validation.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_execution_function.py
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
def test_eof_functions_contract_call_within_deep_nested(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """
    Test performing a call within a nested callf and verify correct behavior of
    return stack in calling contract.

    TODO: This test belongs in EIP-7069 test folder, not code validation.
    """
    env = Environment()

    nested_callee_address = pre.deploy_contract(code=Op.SSTORE(0, 1) + Op.STOP())
    contract_call_within_deep_nested_callf = Container(
        name="contract_call_within_deep_nested_callf",
        sections=[
            Section.Code(
                code=Op.CALLF[1] + Op.SSTORE(0, 1) + Op.STOP,
            )
        ]
        + [
            # All sections call next section and on return, store a 1
            # to their call stack height key
            Section.Code(
                code=(Op.CALLF[i] + Op.SSTORE(i - 1, 1) + Op.RETF),
                code_outputs=0,
            )
            for i in range(2, MAX_CODE_SECTIONS)
        ]
        + [
            # Last section makes external contract call
            Section.Code(
                code=(
                    Op.EXTCALL(nested_callee_address, 0, 0, 0)
                    + Op.ISZERO
                    + Op.PUSH2(MAX_CODE_SECTIONS - 1)
                    + Op.SSTORE
                    + Op.RETF
                ),
                code_outputs=0,
            )
        ],
    )
    callee_address = pre.deploy_contract(contract_call_within_deep_nested_callf)
    sender = pre.fund_eoa()

    tx = Transaction(
        to=callee_address,
        gas_limit=50000000,
        gas_price=10,
        protected=False,
        data="",
        sender=sender,
    )
    post = {
        callee_address: Account(storage={i: 1 for i in range(MAX_CODE_SECTIONS)}),
        nested_callee_address: Account(
            storage={
                0: 1,
            }
        ),
    }

    state_test(
        env=env,
        pre=pre,
        post=post,
        tx=tx,
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test