Skip to content

test_deep_container()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_deep_container@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_deep_container --fork Osaka

Test a very deeply nested container.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
@pytest.mark.parametrize(
    ["deepest_container", "exception"],
    [
        pytest.param(Container.Code(Op.STOP), None, id="valid"),
        pytest.param(
            Container.Code(code=Op.PUSH0),
            EOFException.MISSING_STOP_OPCODE,
            id="code-error",
        ),
        pytest.param(
            Container(raw_bytes="EF0100A94F5374FCE5EDBC8E2A8697C15331677E6EBF0B"),
            EOFException.INVALID_MAGIC,
            id="structure-error",
        ),
    ],
)
def test_deep_container(
    eof_test: EOFTestFiller, deepest_container: Container, exception: EOFException
):
    """Test a very deeply nested container."""
    container = deepest_container
    last_container = deepest_container
    while len(container) < MAX_INITCODE_SIZE:
        last_container = container
        container = Container(
            sections=[
                Section.Code(
                    code=Op.PUSH0 + Op.PUSH0 + Op.PUSH0 + Op.PUSH0 + Op.EOFCREATE[0] + Op.STOP,
                ),
                Section.Container(
                    container=Container(
                        sections=[
                            Section.Code(
                                code=Op.PUSH0 + Op.PUSH0 + Op.RETURNCONTRACT[0],
                            ),
                            Section.Container(container=last_container),
                        ]
                    )
                ),
            ],
        )

    eof_test(container=last_container, expect_exception=exception)

Parametrized Test Cases

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

Test ID (Abbreviated) deepest_container exception
...fork_Osaka-eof_test-valid b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\x04\x00\x00\x00\x00\x80\x00\x00\x00' None
...fork_Osaka-eof_test-code-error b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\x04\x00\x00\x00\x00\x80\x00\x01_' EOFException.MISSING_STOP_OPCODE
...fork_Osaka-eof_test-structure-error 0xef0100a94f5374fce5edbc8e2a8697c15331677e6ebf0b EOFException.INVALID_MAGIC