Skip to content

test_truncated_container_without_data()

Documentation for tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py::test_truncated_container_without_data@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_size.py::test_truncated_container_without_data --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_size.py::test_truncated_container_without_data --until=PragueEIP7692

This 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/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@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,
):
    """
    This 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(
        data=bytecode[: len(bytecode) - truncation_len],
        expect_exception=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 truncation_len exception
truncation_len_0-exception_EOFException.UNREACHABLE_INSTRUCTIONS 0 EOFException.UNREACHABLE_INSTRUCTIONS
EOF1_truncated_section_2 1 EOFException.INVALID_SECTION_BODIES_SIZE
EOF1_truncated_section_1 3 EOFException.INVALID_SECTION_BODIES_SIZE
EOF1_truncated_section_0 6 EOFException.INVALID_SECTION_BODIES_SIZE