Skip to content

test_eof_calls_legacy_mstore()

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

Test EOF contracts calling Legacy contracts that return data.

Source code in tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
@pytest.mark.parametrize(
    "opcode",
    [
        Op.EXTCALL,
        Op.EXTDELEGATECALL,
        Op.EXTSTATICCALL,
    ],
)
def test_eof_calls_legacy_mstore(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    opcode: Op,
):
    """Test EOF contracts calling Legacy contracts that return data."""
    env = Environment()
    destination_contract_code = Op.MSTORE8(
        0, int.from_bytes(value_returndata_magic, "big")
    ) + Op.RETURN(0, 32)
    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_returndatasize, Op.RETURNDATASIZE)
                + Op.SSTORE(slot_returndata, Op.RETURNDATALOAD(0))
                + 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
        slot_returndatasize: 0x20,  # type: ignore
        slot_returndata: value_returndata_magic + b"\0" * (0x20 - len(value_returndata_magic)),  # type: ignore
    }

    if opcode == Op.EXTDELEGATECALL:
        # EOF delegate call to legacy is a light failure by rule
        calling_storage[slot_call_result] = EXTCALL_REVERT
        calling_storage[slot_returndatasize] = 0
        calling_storage[slot_returndata] = 0

    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-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