Skip to content

test_truncated_container_without_data()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py::test_truncated_container_without_data@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py::test_truncated_container_without_data --fork Osaka

Test takes a semi-valid container and removes some bytes from its tail. Migrated from EOFTests/efValidation/EOF1_truncated_section_.json (cases without data section).

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@pytest.mark.parametrize(
    "truncation_len, exception",
    [
        # The original container is not valid by itself because its 2-byte code section
        # starts with the terminating instruction: INVALID.
        pytest.param(0, EOFException.UNREACHABLE_INSTRUCTIONS),
        pytest.param(1, EOFException.INVALID_SECTION_BODIES_SIZE, id="EOF1_truncated_section_2"),
        pytest.param(3, EOFException.INVALID_SECTION_BODIES_SIZE, id="EOF1_truncated_section_1"),
        pytest.param(6, EOFException.INVALID_SECTION_BODIES_SIZE, id="EOF1_truncated_section_0"),
    ],
)
def test_truncated_container_without_data(
    eof_test: EOFTestFiller,
    truncation_len: int,
    exception: EOFException,
):
    """
    Test takes a semi-valid container and removes some bytes from its tail.
    Migrated from EOFTests/efValidation/EOF1_truncated_section_.json (cases without data section).
    """
    container = Container(sections=[Section.Code(Op.INVALID + Op.INVALID)])
    bytecode = bytes(container)
    eof_test(
        container=bytecode[: len(bytecode) - truncation_len],
        expect_exception=exception,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) truncation_len exception
...fork_Osaka-eof_test-truncation_len_0-exception_EOFException.UNREACHABLE_INSTRUCTIONS 0 EOFException.UNREACHABLE_INSTRUCTIONS
...fork_Osaka-eof_test-EOF1_truncated_section_2 1 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1_truncated_section_1 3 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1_truncated_section_0 6 EOFException.INVALID_SECTION_BODIES_SIZE