Skip to content

test_legacy_calls_eof_mstore()

Documentation for tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_legacy_calls_eof_mstore@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_mstore --fork Osaka

Test legacy contracts calling EOF contracts that only return data.

Source code in tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@pytest.mark.parametrize(
    "opcode",
    [
        Op.CALL,
        Op.DELEGATECALL,
        Op.CALLCODE,
        Op.STATICCALL,
    ],
)
def test_legacy_calls_eof_mstore(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    opcode: Op,
):
    """Test legacy contracts calling EOF contracts that only return data."""
    env = Environment()
    destination_contract_code = Container(
        sections=[
            Section.Code(
                code=Op.MSTORE8(0, int.from_bytes(value_returndata_magic, "big"))
                + Op.RETURN(0, len(value_returndata_magic)),
            )
        ]
    )
    destination_contract_address = pre.deploy_contract(destination_contract_code)

    caller_contract = (
        Op.SSTORE(slot_call_result, opcode(address=destination_contract_address))
        + Op.SSTORE(slot_returndatasize, Op.RETURNDATASIZE)
        + Op.RETURNDATACOPY(31, 0, 1)
        + Op.SSTORE(slot_returndata, Op.MLOAD(0))
        + 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 = {
        slot_code_worked: value_code_worked,  # type: ignore
        slot_call_result: LEGACY_CALL_SUCCESS,  # type: ignore
        slot_returndatasize: len(value_returndata_magic),  # type: ignore
        slot_returndata: value_returndata_magic,  # type: ignore
    }

    post = {
        calling_contract_address: Account(storage=calling_storage),
        destination_contract_address: Account(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