Skip to content

test_all_unreachable_terminating_opcodes_after_stop()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py::test_all_unreachable_terminating_opcodes_after_stop@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py::test_all_unreachable_terminating_opcodes_after_stop --fork Osaka

Test all terminating opcodes after stop.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
@pytest.mark.parametrize(
    "opcode",
    sorted(halting_opcodes | section_terminating_opcodes),
)
def test_all_unreachable_terminating_opcodes_after_stop(
    eof_test: EOFTestFiller,
    opcode: Opcode,
):
    """Test all terminating opcodes after stop."""
    match opcode:
        case Op.STOP:
            sections = [Section.Code(code=Op.STOP + Op.STOP)]
        case Op.RETF:
            sections = [
                Section.Code(code=Op.CALLF[1] + Op.STOP),
                Section.Code(code=Op.STOP + Op.RETF, code_outputs=0),
            ]
        case Op.JUMPF:
            sections = [
                Section.Code(code=Op.STOP + Op.JUMPF[1]),
                Section.Code(code=Op.STOP),
            ]
        case Op.RETURNCONTRACT:
            sections = [
                Section.Code(code=Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section.Container(
                    container=Container(
                        sections=[
                            Section.Code(code=Op.STOP + Op.RETURNCONTRACT[0](0, 0)),
                            Section.Container(Container.Code(code=Op.STOP)),
                        ]
                    )
                ),
            ]
        case Op.RETURN | Op.REVERT | Op.INVALID:
            sections = [
                Section.Code(code=Op.PUSH0 + Op.PUSH0 + Op.STOP + opcode),
            ]
        case _:
            raise NotImplementedError(f"Opcode {opcode} is not implemented")

    eof_test(
        container=Container(
            sections=sections,
        ),
        expect_exception=EOFException.UNREACHABLE_INSTRUCTIONS
        if opcode != Op.RETURNCONTRACT
        else EOFException.INCOMPATIBLE_CONTAINER_KIND,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) opcode
...fork_Osaka-eof_test-opcode_STOP STOP
...fork_Osaka-eof_test-opcode_RETF RETF
...fork_Osaka-eof_test-opcode_JUMPF JUMPF
...fork_Osaka-eof_test-opcode_RETURNCONTRACT RETURNCONTRACT
...fork_Osaka-eof_test-opcode_RETURN RETURN
...fork_Osaka-eof_test-opcode_REVERT REVERT
...fork_Osaka-eof_test-opcode_INVALID INVALID