Skip to content

test_max_code_size()

Documentation for tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py::test_max_code_size@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py::test_max_code_size --fork Amsterdam

Ensure the new max code size boundary is enforced.

Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py
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
@pytest.mark.parametrize("deploy_code_size", DEPLOY_CODE_SIZE_PARAMS)
def test_max_code_size(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    deploy_code_size: Callable[[Fork], int],
) -> None:
    """Ensure the new max code size boundary is enforced."""
    code_size = deploy_code_size(fork)
    deploy_code = Op.JUMPDEST * code_size

    alice = pre.fund_eoa()
    initcode = Initcode(deploy_code=deploy_code)
    create_address = compute_create_address(address=alice, nonce=0)

    tx = Transaction(
        sender=alice,
        to=None,
        data=initcode,
    )

    post: dict[Any, Account | None] = {}
    if code_size <= fork.max_code_size():
        post[create_address] = Account(code=deploy_code)
    else:
        post[create_address] = Account.NONEXISTENT

    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.