Skip to content

test_over_max_initcode_size_mainnet()

Documentation for tests/amsterdam/eip7954_increase_max_contract_size/test_eip_mainnet.py::test_over_max_initcode_size_mainnet@2119b382.

Generate fixtures for these test cases for Amsterdam with:

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

Verify a CREATE transaction over the new initcode limit is rejected.

Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_eip_mainnet.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@pytest.mark.exception_test
def test_over_max_initcode_size_mainnet(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """Verify a CREATE transaction over the new initcode limit is rejected."""
    initcode = Initcode(
        deploy_code=Op.STOP,
        initcode_length=fork.max_initcode_size() + 1,
    )

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

    tx = Transaction(
        sender=alice,
        to=None,
        data=initcode,
        gas_limit=fork.transaction_gas_limit_cap(),
        error=TransactionException.INITCODE_SIZE_EXCEEDED,
    )

    post: dict[Any, Account | None] = {
        create_address: Account.NONEXISTENT,
    }

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.