Skip to content

test_unreachable_code_sections()

Documentation for tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py::test_unreachable_code_sections@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py::test_unreachable_code_sections --fork Osaka

Test cases for EOF unreachable code sections (i.e. code sections not reachable from the code section 0).

Source code in tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
@pytest.mark.parametrize(
    "container",
    [
        Container(
            name="unreachable1",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.INVALID),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_selfjumpf",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.JUMPF[1]),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_selfcallf",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[1] + Op.STOP),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_jumpf0",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.JUMPF[0]),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_callf0",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[0] + Op.STOP),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_selfcall_jumpf0",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[1] + Op.JUMPF[0]),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_2jumpf1",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.STOP),  # unreachable
                Section.Code(Op.JUMPF[1]),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_2callf1",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.STOP),  # unreachable
                Section.Code(Op.CALLF[1] + Op.STOP),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_jumpf_loop",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.JUMPF[2]),  # unreachable
                Section.Code(Op.JUMPF[1]),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_callf_loop_stop",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[2] + Op.STOP),  # unreachable
                Section.Code(Op.CALLF[1] + Op.STOP),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_callf_loop_retf",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[2] + Op.RETF, code_outputs=0),  # unreachable
                Section.Code(Op.CALLF[1] + Op.RETF, code_outputs=0),  # unreachable
            ],
        ),
        Container(
            name="unreachable12_of3_callf_loop_mixed",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.CALLF[2] + Op.STOP),  # unreachable
                Section.Code(Op.CALLF[1] + Op.RETF, code_outputs=0),  # unreachable
            ],
        ),
        Container(
            name="selfjumpf0_unreachable1",
            sections=[
                Section.Code(Op.JUMPF[0]),  # self-reference
                Section.Code(Op.JUMPF[1]),  # unreachable
            ],
        ),
        Container(
            name="unreachable2_of3",
            sections=[
                Section.Code(Op.CALLF[1] + Op.STOP),
                Section.Code(Op.RETF, code_outputs=0),
                Section.Code(Op.INVALID),  # unreachable
            ],
        ),
        Container(
            name="unreachable1_of3",
            sections=[
                Section.Code(Op.CALLF[2] + Op.STOP),
                Section.Code(Op.INVALID),  # unreachable
                Section.Code(Op.RETF, code_outputs=0),
            ],
        ),
        Container(
            name="unreachable1_of4",
            sections=[
                Section.Code(Op.CALLF[3] + Op.STOP),
                Section.Code(Op.INVALID),  # unreachable
                Section.Code(Op.RETF, code_outputs=0),
                Section.Code(Op.CALLF[2] + Op.RETF, code_outputs=0),
            ],
        ),
        Container(
            name="unreachable2_of3_retf",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.STOP),
                Section.Code(Op.RETF, code_outputs=0),
            ],
        ),
        Container(
            name="unreachable2-255",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.JUMPF[1]),  # self-reference
            ]
            + [Section.Code(Op.JUMPF[i]) for i in range(3, 255)]  # unreachable
            + [Section.Code(Op.STOP)],  # unreachable
        ),
        Container(
            name="unreachable255",
            sections=[Section.Code(Op.JUMPF[i]) for i in range(1, 255)]
            + [
                Section.Code(Op.JUMPF[254]),  # self-reference
                Section.Code(Op.STOP),  # unreachable
            ],
        ),
    ],
    ids=container_name,
)
def test_unreachable_code_sections(
    eof_test: EOFTestFiller,
    container: Container,
):
    """
    Test cases for EOF unreachable code sections
    (i.e. code sections not reachable from the code section 0).
    """
    eof_test(container=container, expect_exception=EOFException.UNREACHABLE_CODE_SECTIONS)

Parametrized Test Cases

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

Test ID (Abbreviated) container
...fork_Osaka-eof_test-unreachable1 unreachable1
...fork_Osaka-eof_test-unreachable1_selfjumpf unreachable1_selfjumpf
...fork_Osaka-eof_test-unreachable1_selfcallf unreachable1_selfcallf
...fork_Osaka-eof_test-unreachable1_jumpf0 unreachable1_jumpf0
...fork_Osaka-eof_test-unreachable1_callf0 unreachable1_callf0
...fork_Osaka-eof_test-unreachable1_selfcall_jumpf0 unreachable1_selfcall_jumpf0
...fork_Osaka-eof_test-unreachable12_of3_2jumpf1 unreachable12_of3_2jumpf1
...fork_Osaka-eof_test-unreachable12_of3_2callf1 unreachable12_of3_2callf1
...fork_Osaka-eof_test-unreachable12_of3_jumpf_loop unreachable12_of3_jumpf_loop
...fork_Osaka-eof_test-unreachable12_of3_callf_loop_stop unreachable12_of3_callf_loop_stop
...fork_Osaka-eof_test-unreachable12_of3_callf_loop_retf unreachable12_of3_callf_loop_retf
...fork_Osaka-eof_test-unreachable12_of3_callf_loop_mixed unreachable12_of3_callf_loop_mixed
...fork_Osaka-eof_test-selfjumpf0_unreachable1 selfjumpf0_unreachable1
...fork_Osaka-eof_test-unreachable2_of3 unreachable2_of3
...fork_Osaka-eof_test-unreachable1_of3 unreachable1_of3
...fork_Osaka-eof_test-unreachable1_of4 unreachable1_of4
...fork_Osaka-eof_test-unreachable2_of3_retf unreachable2_of3_retf
...fork_Osaka-eof_test-unreachable2-255 unreachable2-255
...fork_Osaka-eof_test-unreachable255 unreachable255