Skip to content

test_callf()

Documentation for tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf@008e492e.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf --fork Osaka

Test basic usage of CALLF and RETF instructions.

Source code in tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
@pytest.mark.parametrize(
    "container",
    (
        Container(
            name="callf_sub_retf",
            sections=[
                Section.Code(
                    Op.SSTORE(
                        slot_code_worked,
                        Op.PUSH1[1] + Op.PUSH2[value_code_worked + 1] + Op.CALLF[1],
                    )
                    + Op.STOP,
                    max_stack_height=2,
                ),
                Section.Code(
                    Op.SUB + Op.RETF,
                    code_inputs=2,
                    code_outputs=1,
                    max_stack_height=2,
                ),
            ],
        ),
        Container(
            name="max_code_sections_retf2",
            sections=[
                Section.Code(
                    Op.CALLF[1] + Op.SSTORE + Op.STOP,
                    max_stack_height=2,
                )
            ]
            + [
                Section.Code(
                    Op.CALLF[i] + Op.RETF,
                    code_inputs=0,
                    code_outputs=2,
                    max_stack_height=2,
                )
                for i in range(2, 1024)
            ]
            + [
                Section.Code(
                    Op.PUSH2[value_code_worked] + Op.PUSH1[slot_code_worked] + Op.RETF,
                    code_inputs=0,
                    code_outputs=2,
                    max_stack_height=2,
                ),
            ],
        ),
        Container(
            name="multiple_sections_of_different_types",  # EOF1V4750_0005
            sections=[
                Section.Code(
                    Op.PUSH0
                    + Op.CALLF[1]
                    + Op.CALLF[2]
                    + Op.PUSH0
                    + Op.CALLF[3]
                    + Op.SSTORE
                    + Op.STOP,
                    max_stack_height=4,
                ),
                Section.Code(
                    Op.POP + Op.RETF,
                    code_inputs=1,
                    code_outputs=0,
                    max_stack_height=1,
                ),
                Section.Code(
                    Op.PUSH2[value_code_worked] + Op.RETF,
                    code_inputs=0,
                    code_outputs=1,
                    max_stack_height=1,
                ),
                Section.Code(
                    Op.DUP2 + Op.PUSH2[slot_code_worked] + Op.RETF,
                    code_inputs=2,
                    code_outputs=4,
                    max_stack_height=4,
                ),
            ],
        ),
    ),
    ids=lambda x: x.name,
)
def test_callf(eof_state_test: EOFStateTestFiller, container: Container):
    """Test basic usage of CALLF and RETF instructions."""
    eof_state_test(
        container=container,
        container_post=Account(storage={slot_code_worked: value_code_worked}),
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated) container
...fork_Osaka-eof_test-callf_sub_retf callf_sub_retf
...fork_Osaka-eof_test-max_code_sections_retf2 max_code_sections_retf2
...fork_Osaka-eof_test-multiple_sections_of_different_types multiple_sections_of_different_types
...fork_Osaka-eof_state_test-callf_sub_retf callf_sub_retf
...fork_Osaka-eof_state_test-max_code_sections_retf2 max_code_sections_retf2
...fork_Osaka-eof_state_test-multiple_sections_of_different_types multiple_sections_of_different_types
...fork_Osaka-eof_blockchain_test-callf_sub_retf callf_sub_retf
...fork_Osaka-eof_blockchain_test-max_code_sections_retf2 max_code_sections_retf2
...fork_Osaka-eof_blockchain_test-multiple_sections_of_different_types multiple_sections_of_different_types