Skip to content

test_callee_fails()

Documentation for tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py::test_callee_fails@008e492e.

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
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
573
574
575
576
577
578
579
580
581
@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=Address(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\x04\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\x04\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\x04\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\x04\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\x04\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\x04\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%\x04\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%\x04\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%\x04\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\x04\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\x04\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\x04\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\x04\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\x04\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\x04\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%\x04\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%\x04\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%\x04\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