Skip to content

test_truncated_container_with_data()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py::test_truncated_container_with_data@49a16fac.

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_with_data --fork Osaka

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

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
@pytest.mark.parametrize(
    "truncation_len, exception",
    [
        pytest.param(0, None),
        pytest.param(1, EOFException.TOPLEVEL_CONTAINER_TRUNCATED, id="EOF1_truncated_section_4"),
        pytest.param(2, EOFException.TOPLEVEL_CONTAINER_TRUNCATED, id="EOF1_truncated_section_3"),
    ],
)
def test_truncated_container_with_data(
    eof_test: EOFTestFiller,
    truncation_len: int,
    exception: EOFException,
):
    """
    Test takes a valid container with data and removes some bytes from its tail.
    Migrated from EOFTests/efValidation/EOF1_truncated_section_.json (cases with data section).
    """
    data = b"\xaa\xbb"
    container = Container(
        sections=[
            Section.Code(Op.INVALID),
            Section.Data(data[0 : (len(data) - truncation_len)], custom_size=2),
        ]
    )
    eof_test(
        container=container,
        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_None 0 None
...fork_Osaka-eof_test-EOF1_truncated_section_4 1 EOFException.TOPLEVEL_CONTAINER_TRUNCATED
...fork_Osaka-eof_test-EOF1_truncated_section_3 2 EOFException.TOPLEVEL_CONTAINER_TRUNCATED