Skip to content

test_code_section_header_body_mismatch()

Documentation for tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_header_body_mismatch.py::test_code_section_header_body_mismatch@verkle@v0.0.6.

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_header_body_mismatch.py::test_code_section_header_body_mismatch --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_header_body_mismatch.py::test_code_section_header_body_mismatch --until=PragueEIP7692

Inconsistent number of code sections (between types and code)

Source code in tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_header_body_mismatch.py
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
@pytest.mark.parametrize(
    **extend_with_defaults(
        defaults=dict(
            skip_header_listing=False,  # second section is mentioned in code header array
            skip_body_listing=False,  # second section code is in container's body
            skip_types_body_listing=False,  # code input bytes not listed in container's body
            skip_types_header_listing=False,  # code input bytes size not added to types section size  # noqa: E501
            expected_code="",
            expected_exception=None,
        ),
        cases=[
            pytest.param(
                dict(
                    skip_header_listing=True,
                    skip_body_listing=True,
                    expected_code="ef000101000802000100030400040000800001000000003050000bad60A7",
                    expected_exception=[
                        EOFException.INVALID_TYPE_SECTION_SIZE,
                        EOFException.INVALID_SECTION_BODIES_SIZE,
                    ],
                ),
                id="drop_code_section_and_header",
            ),
            pytest.param(
                dict(
                    skip_header_listing=True,
                    skip_body_listing=False,
                    expected_code="ef000101000802000100030400040000800001000000003050003050000bad60A7",  # noqa: E501
                    expected_exception=[
                        EOFException.INVALID_TYPE_SECTION_SIZE,
                        EOFException.INVALID_SECTION_BODIES_SIZE,
                    ],
                ),
                id="drop_code_header",
            ),
            pytest.param(
                dict(
                    skip_header_listing=False,
                    skip_body_listing=True,
                    expected_code="ef0001010008020002000300030400040000800001000000003050000bad60A7",  # noqa: E501
                    expected_exception=[
                        EOFException.UNREACHABLE_CODE_SECTIONS,
                        EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
                    ],
                ),
                id="drop_code_section",
            ),
            pytest.param(
                dict(
                    skip_header_listing=False,
                    skip_body_listing=False,
                    expected_code="ef0001010008020002000300030400040000800001000000003050003050000bad60A7",  # noqa: E501
                    expected_exception=EOFException.UNREACHABLE_CODE_SECTIONS,
                ),
                id="layout_ok_code_bad",
            ),
            pytest.param(
                dict(
                    skip_header_listing=True,
                    skip_body_listing=True,
                    skip_types_body_listing=True,
                    expected_code="ef0001010008020001000304000400008000013050000bad60a7",
                    expected_exception=[
                        EOFException.INVALID_TYPE_SECTION_SIZE,
                        EOFException.INVALID_SECTION_BODIES_SIZE,
                    ],
                ),
                id="drop_types_header",
            ),
            pytest.param(
                dict(
                    skip_header_listing=True,
                    skip_body_listing=True,
                    skip_types_body_listing=True,
                    skip_types_header_listing=True,
                    expected_code="ef0001010004020001000304000400008000013050000bad60a7",
                    expected_exception=None,
                ),
                id="drop_everything",
            ),
        ],
    )
)
def test_code_section_header_body_mismatch(
    eof_test: EOFTestFiller,
    skip_header_listing: bool,
    skip_body_listing: bool,
    skip_types_body_listing: bool,
    skip_types_header_listing: bool,
    expected_code: str,
    expected_exception: EOFExceptionInstanceOrList | None,
):
    """
    Inconsistent number of code sections (between types and code)
    """
    eof_code = Container(
        name="EOF1I0018",
        sections=[
            Section.Code(
                code=Op.ADDRESS + Op.POP + Op.STOP,
            ),
            Section.Code(
                code=Op.ADDRESS + Op.POP + Op.STOP,
                code_inputs=0,
                code_outputs=0,
                max_stack_height=0,
                # whether to not mention it in code section header list
                skip_header_listing=skip_header_listing,
                # whether to not print its code in containers body
                skip_body_listing=skip_body_listing,
                # whether to not print its input bytes in containers body
                skip_types_body_listing=skip_types_body_listing,
                # whether to not calculate its input bytes size in types section's header
                skip_types_header_listing=skip_types_header_listing,
            ),
            Section.Data("0x0bad60A7"),
        ],
    )

    # TODO remove this after Container class implementation is reliable
    assert bytes(eof_code).hex() == bytes.fromhex(expected_code).hex()

    eof_test(
        data=eof_code,
        expect_exception=expected_exception,
    )

Parametrized Test Cases

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID skip_header_listing skip_body_listing skip_types_body_listing skip_types_header_listing expected_code expected_exception
drop_code_section_and_header True True False False ef000101000802000100030400040000800001000000003050000bad60A7 [, ]
drop_code_header True False False False ef000101000802000100030400040000800001000000003050003050000bad60A7 [, ]
drop_code_section False True False False ef0001010008020002000300030400040000800001000000003050000bad60A7 [, ]
layout_ok_code_bad False False False False ef0001010008020002000300030400040000800001000000003050003050000bad60A7 EOFException.UNREACHABLE_CODE_SECTIONS
drop_types_header True True True False ef0001010008020001000304000400008000013050000bad60a7 [, ]
drop_everything True True True True ef0001010004020001000304000400008000013050000bad60a7 None