Skip to content

test_eof_creation_tx_context()

Documentation for tests/osaka/eip7692_eof_v1/eip7698_eof_creation_tx/test_eof_creation_tx.py::test_eof_creation_tx_context@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7698_eof_creation_tx/test_eof_creation_tx.py::test_eof_creation_tx_context --fork Osaka

Test EOF creation txs' initcode context instructions.

Source code in tests/osaka/eip7692_eof_v1/eip7698_eof_creation_tx/test_eof_creation_tx.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@pytest.mark.parametrize(
    ["destination_code", "expected_result"],
    [
        pytest.param(Op.ADDRESS, "destination"),
        pytest.param(Op.CALLER, "sender"),
        pytest.param(Op.CALLVALUE, "value"),
        pytest.param(Op.ORIGIN, "sender"),
    ],
)
def test_eof_creation_tx_context(
    state_test: StateTestFiller,
    pre: Alloc,
    destination_code: Bytecode,
    expected_result: str,
):
    """Test EOF creation txs' initcode context instructions."""
    env = Environment()
    sender = pre.fund_eoa()
    value = 0x1123

    initcode = Container(
        sections=[
            Section.Code(
                Op.SSTORE(slot_call_result, destination_code) + Op.RETURNCONTRACT[0](0, 0)
            ),
            Section.Container(smallest_runtime_subcontainer),
        ]
    )

    tx = Transaction(sender=sender, to=None, gas_limit=100000, value=value, input=initcode)

    destination_contract_address = tx.created_contract

    expected_bytes: Address | int
    if expected_result == "destination":
        expected_bytes = destination_contract_address
    elif expected_result == "sender":
        expected_bytes = sender
    elif expected_result == "value":
        expected_bytes = value
    else:
        raise TypeError("Unexpected expected_result", expected_result)

    destination_contract_storage = {
        slot_call_result: expected_bytes,
    }

    post = {
        destination_contract_address: Account(storage=destination_contract_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
...fork_Osaka-state_test-destination_code_ADDRESS-expected_result_destination ADDRESS destination
...fork_Osaka-state_test-destination_code_CALLER-expected_result_sender CALLER sender
...fork_Osaka-state_test-destination_code_CALLVALUE-expected_result_value CALLVALUE value
...fork_Osaka-state_test-destination_code_ORIGIN-expected_result_sender ORIGIN sender
...fork_Osaka-blockchain_test_from_state_test-destination_code_ADDRESS-expected_result_destination ADDRESS destination
...fork_Osaka-blockchain_test_from_state_test-destination_code_CALLER-expected_result_sender CALLER sender
...fork_Osaka-blockchain_test_from_state_test-destination_code_CALLVALUE-expected_result_value CALLVALUE value
...fork_Osaka-blockchain_test_from_state_test-destination_code_ORIGIN-expected_result_sender ORIGIN sender