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@9c2813ee.

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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
@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=14_999,
            txs=[
                Transaction(
                    sender=alice,
                    to=None,
                    data=initcode,
                    gas_limit=fork.transitions_from().transaction_gas_limit_cap(),
                    error=initcode_too_large,
                )
            ],
            exception=initcode_too_large,
        ),
        Block(
            timestamp=15_000,
            txs=[
                Transaction(
                    sender=bob,
                    to=None,
                    data=initcode,
                    gas_limit=fork.transitions_to().transaction_gas_limit_cap(),
                )
            ],
        ),
    ]

    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.