Skip to content

test_eof_calls_legacy_sstore()

Documentation for tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_eof_calls_legacy_sstore@bc691d13.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_eof_calls_legacy_sstore --fork Osaka

Test EOF contracts calling Legacy contracts that use SSTORE.

Source code in tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
@pytest.mark.parametrize(
    "opcode",
    [
        Op.EXTCALL,
        Op.EXTDELEGATECALL,
        Op.EXTSTATICCALL,
    ],
)
def test_eof_calls_legacy_sstore(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    opcode: Op,
):
    """Test EOF contracts calling Legacy contracts that use SSTORE."""
    env = Environment()
    destination_contract_code = Op.SSTORE(slot_caller, Op.CALLER()) + Op.STOP
    destination_contract_address = pre.deploy_contract(destination_contract_code)

    caller_contract = Container(
        sections=[
            Section.Code(
                code=Op.SSTORE(slot_call_result, opcode(address=destination_contract_address))
                + Op.SSTORE(slot_code_worked, value_code_worked)
                + Op.STOP,
            )
        ]
    )
    calling_contract_address = pre.deploy_contract(caller_contract)

    tx = Transaction(
        sender=sender,
        to=calling_contract_address,
        gas_limit=50000000,
    )

    calling_storage = {
        slot_code_worked: value_code_worked,  # type: ignore
        slot_call_result: EXTCALL_SUCCESS,  # type: ignore
    }
    destination_storage = {}

    if opcode == Op.EXTCALL:
        destination_storage[slot_caller] = calling_contract_address
    elif opcode == Op.EXTDELEGATECALL:
        # EOF delegate call to legacy is a light failure by rule
        calling_storage[slot_call_result] = EXTCALL_REVERT
    elif opcode == Op.EXTSTATICCALL:
        calling_storage[slot_call_result] = EXTCALL_FAILURE

    post = {
        calling_contract_address: Account(storage=calling_storage),
        destination_contract_address: Account(storage=destination_storage),
    }

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

Parametrized Test Cases

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

Test ID (Abbreviated) opcode
...fork_Osaka-state_test-opcode_EXTCALL EXTCALL
...fork_Osaka-state_test-opcode_EXTDELEGATECALL EXTDELEGATECALL
...fork_Osaka-state_test-opcode_EXTSTATICCALL EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-opcode_EXTCALL EXTCALL
...fork_Osaka-blockchain_test_from_state_test-opcode_EXTDELEGATECALL EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-opcode_EXTSTATICCALL EXTSTATICCALL