Skip to content

test_max_size()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_size.py::test_max_size@49a16fac.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_size.py::test_max_size --fork Osaka

Verify EOF container valid at maximum size, invalid above.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_size.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@pytest.mark.parametrize(
    "over_limit",
    [0, 1, 2, 2**16 - MAX_INITCODE_SIZE],
)
def test_max_size(
    eof_test: EOFTestFiller,
    over_limit: int,
):
    """Verify EOF container valid at maximum size, invalid above."""
    # Expand the minimal EOF code by more noop code, reaching the desired target container size.
    code = Container(
        sections=[
            Section.Code(
                code=Op.JUMPDEST * (MAX_INITCODE_SIZE - len(VALID_CONTAINER) + over_limit)
                + Op.STOP
            )
        ]
    )
    assert len(code) == MAX_INITCODE_SIZE + over_limit
    eof_test(
        container=bytes(code),
        expect_exception=None if over_limit == 0 else EOFException.CONTAINER_SIZE_ABOVE_LIMIT,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) over_limit
...fork_Osaka-eof_test-over_limit_0 0
...fork_Osaka-eof_test-over_limit_1 1
...fork_Osaka-eof_test-over_limit_2 2
...fork_Osaka-eof_test-over_limit_16384 16384