Skip to content

test_max_code_size_with_max_initcode_fork_transition()

Documentation for tests/amsterdam/eip7954_increase_max_contract_size/test_fork_transition.py::test_max_code_size_with_max_initcode_fork_transition@ffe48572.

Generate fixtures for these test cases for Amsterdam with:

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

Ensure max code + max initcode activates at the fork boundary.

Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_fork_transition.py
@pytest.mark.exception_test
def test_max_code_size_with_max_initcode_fork_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: TransitionFork,
) -> None:
    """Ensure max code + max initcode activates at the fork boundary."""
    deploy_code = Op.JUMPDEST * fork.transitions_to().max_code_size()
    initcode = Initcode(
        deploy_code=deploy_code,
        initcode_length=fork.transitions_to().max_initcode_size(),
    )

    alice = pre.fund_eoa()
    bob = pre.fund_eoa()

    create_address_post = compute_create_address(address=bob, nonce=0)

    initcode_too_large = TransactionException.INITCODE_SIZE_EXCEEDED

    blocks = [
        Block(
            timestamp=PRE_FORK_TIMESTAMP,
            txs=[
                Transaction(
                    sender=alice,
                    to=None,
                    data=initcode,
                    error=initcode_too_large,
                )
            ],
            exception=initcode_too_large,
        ),
        Block(
            timestamp=POST_FORK_TIMESTAMP,
            txs=[
                Transaction(
                    sender=bob,
                    to=None,
                    data=initcode,
                )
            ],
        ),
    ]

    post: dict[Any, Account | None] = {
        create_address_post: Account(code=deploy_code),
    }

    blockchain_test(pre=pre, blocks=blocks, post=post)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.