Skip to content

test_callee_fails()

Documentation for tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_callee_fails@3719e927.

Generate fixtures for these test cases for Osaka with:

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

Test EOF contracts calling contracts that fail for various reasons.

Source code in tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
@pytest.mark.parametrize(
    "opcode",
    [
        Op.EXTCALL,
        Op.EXTDELEGATECALL,
        Op.EXTSTATICCALL,
    ],
)
@pytest.mark.parametrize(
    ["destination_code", "expected_result"],
    [
        pytest.param(Op.REVERT(0, 0), EXTCALL_REVERT, id="legacy_revert"),
        pytest.param(Op.INVALID, EXTCALL_FAILURE, id="legacy_invalid"),
        pytest.param(Op.SHA3(0, 2**255), EXTCALL_FAILURE, id="legacy_oog"),
        pytest.param(Op.RETURNDATACOPY(0, 1, 2), EXTCALL_FAILURE, id="legacy_oob_returndata"),
        pytest.param(Container.Code(Op.REVERT(0, 0)), EXTCALL_REVERT, id="eof_revert"),
        pytest.param(Container.Code(Op.INVALID), EXTCALL_FAILURE, id="eof_invalid"),
        pytest.param(Container.Code(Op.SHA3(0, 2**255) + Op.STOP), EXTCALL_FAILURE, id="eof_oog"),
    ],
)
def test_callee_fails(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    opcode: Op,
    destination_code: Bytecode | Container,
    expected_result: int,
):
    """Test EOF contracts calling contracts that fail for various reasons."""
    env = Environment()

    destination_contract_address = pre.deploy_contract(destination_code)

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

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

    calling_storage = {
        slot_code_worked: value_code_worked,
        slot_call_result: EXTCALL_REVERT
        if opcode == Op.EXTDELEGATECALL and not isinstance(destination_code, Container)
        else expected_result,
    }

    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) destination_code expected_result opcode
...fork_Osaka-state_test-legacy_revert-opcode_EXTCALL 1 EXTCALL
...fork_Osaka-state_test-legacy_revert-opcode_EXTDELEGATECALL 1 EXTDELEGATECALL
...fork_Osaka-state_test-legacy_revert-opcode_EXTSTATICCALL 1 EXTSTATICCALL
...fork_Osaka-state_test-legacy_invalid-opcode_EXTCALL INVALID 2 EXTCALL
...fork_Osaka-state_test-legacy_invalid-opcode_EXTDELEGATECALL INVALID 2 EXTDELEGATECALL
...fork_Osaka-state_test-legacy_invalid-opcode_EXTSTATICCALL INVALID 2 EXTSTATICCALL
...fork_Osaka-state_test-legacy_oog-opcode_EXTCALL 2 EXTCALL
...fork_Osaka-state_test-legacy_oog-opcode_EXTDELEGATECALL 2 EXTDELEGATECALL
...fork_Osaka-state_test-legacy_oog-opcode_EXTSTATICCALL 2 EXTSTATICCALL
...fork_Osaka-state_test-legacy_oob_returndata-opcode_EXTCALL 2 EXTCALL
...fork_Osaka-state_test-legacy_oob_returndata-opcode_EXTDELEGATECALL 2 EXTDELEGATECALL
...fork_Osaka-state_test-legacy_oob_returndata-opcode_EXTSTATICCALL 2 EXTSTATICCALL
...fork_Osaka-state_test-eof_revert-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTCALL
...fork_Osaka-state_test-eof_revert-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTDELEGATECALL
...fork_Osaka-state_test-eof_revert-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTSTATICCALL
...fork_Osaka-state_test-eof_invalid-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTCALL
...fork_Osaka-state_test-eof_invalid-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTDELEGATECALL
...fork_Osaka-state_test-eof_invalid-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTSTATICCALL
...fork_Osaka-state_test-eof_oog-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTCALL
...fork_Osaka-state_test-eof_oog-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTDELEGATECALL
...fork_Osaka-state_test-eof_oog-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_revert-opcode_EXTCALL 1 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_revert-opcode_EXTDELEGATECALL 1 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-legacy_revert-opcode_EXTSTATICCALL 1 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_invalid-opcode_EXTCALL INVALID 2 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_invalid-opcode_EXTDELEGATECALL INVALID 2 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-legacy_invalid-opcode_EXTSTATICCALL INVALID 2 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oog-opcode_EXTCALL 2 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oog-opcode_EXTDELEGATECALL 2 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oog-opcode_EXTSTATICCALL 2 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oob_returndata-opcode_EXTCALL 2 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oob_returndata-opcode_EXTDELEGATECALL 2 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-legacy_oob_returndata-opcode_EXTSTATICCALL 2 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-eof_revert-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-eof_revert-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-eof_revert-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x05\xff\x00\x00\x00\x00\x80\x00\x02`\x00`\x00\xfd' 1 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-eof_invalid-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-eof_invalid-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-eof_invalid-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\xfe' 2 EXTSTATICCALL
...fork_Osaka-blockchain_test_from_state_test-eof_oog-opcode_EXTCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTCALL
...fork_Osaka-blockchain_test_from_state_test-eof_oog-opcode_EXTDELEGATECALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTDELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-eof_oog-opcode_EXTSTATICCALL b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00%\xff\x00\x00\x00\x00\x80\x00\x02\x7f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00 \x00' 2 EXTSTATICCALL