Skip to content

test_legacy_calls_eof_sstore()

Documentation for tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_legacy_calls_eof_sstore@49a16fac.

Generate fixtures for these test cases for Osaka with:

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

Test legacy contracts calling EOF contracts that use SSTORE.

Source code in tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@pytest.mark.parametrize(
    "opcode",
    [
        Op.CALL,
        Op.DELEGATECALL,
        Op.CALLCODE,
        Op.STATICCALL,
    ],
)
def test_legacy_calls_eof_sstore(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    opcode: Op,
):
    """Test legacy contracts calling EOF contracts that use SSTORE."""
    env = Environment()
    destination_contract_address = pre.deploy_contract(contract_eof_sstore)

    caller_contract = Op.SSTORE(
        slot_call_result, opcode(address=destination_contract_address)
    ) + Op.SSTORE(slot_code_worked, value_code_worked)

    calling_contract_address = pre.deploy_contract(caller_contract)

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

    calling_storage = Storage(
        {
            slot_code_worked: value_code_worked,  # type: ignore
            slot_call_result: LEGACY_CALL_SUCCESS,  # type: ignore
        }
    )
    destination_storage = Storage()

    if opcode == Op.CALL:
        destination_storage[slot_caller] = calling_contract_address
    elif opcode == Op.DELEGATECALL:
        calling_storage[slot_caller] = sender
    elif opcode == Op.CALLCODE:
        calling_storage[slot_caller] = calling_contract_address
    elif opcode == Op.STATICCALL:
        calling_storage[slot_call_result] = LEGACY_CALL_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-blockchain_test-opcode_CALL CALL
...fork_Osaka-blockchain_test-opcode_DELEGATECALL DELEGATECALL
...fork_Osaka-blockchain_test-opcode_CALLCODE CALLCODE
...fork_Osaka-blockchain_test-opcode_STATICCALL STATICCALL
...fork_Osaka-state_test-opcode_CALL CALL
...fork_Osaka-state_test-opcode_DELEGATECALL DELEGATECALL
...fork_Osaka-state_test-opcode_CALLCODE CALLCODE
...fork_Osaka-state_test-opcode_STATICCALL STATICCALL