Skip to content

test_all_unreachable_terminating_opcodes_before_stop()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py::test_all_unreachable_terminating_opcodes_before_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_before_stop --fork Osaka

Test all opcodes terminating opcodes before.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
@pytest.mark.parametrize(
    "opcode",
    sorted((halting_opcodes | section_terminating_opcodes) - {Op.STOP}),
)
def test_all_unreachable_terminating_opcodes_before_stop(
    eof_test: EOFTestFiller,
    opcode: Opcode,
):
    """Test all opcodes terminating opcodes before."""
    match opcode:
        case Op.RETF:
            sections = [
                Section.Code(code=Op.CALLF[1] + Op.STOP),
                Section.Code(code=Op.RETF + Op.STOP, code_outputs=0),
            ]
        case Op.JUMPF:
            sections = [
                Section.Code(code=Op.JUMPF[1] + Op.STOP),
                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.RETURNCONTRACT[0](0, 0) + Op.STOP),
                            Section.Container(Container.Code(code=Op.STOP)),
                        ]
                    )
                ),
            ]
        case Op.RETURN | Op.REVERT | Op.INVALID:
            sections = [
                Section.Code(code=Op.PUSH1(0) + Op.PUSH1(0) + opcode + Op.STOP),
            ]
        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_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