Skip to content

test_parent_max_code_size_across_fork()

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

Generate fixtures for these test cases for Amsterdam with:

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

Ensure previous max code size works after transition.

Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_fork_transition.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
def test_parent_max_code_size_across_fork(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: TransitionFork,
) -> None:
    """Ensure previous max code size works after transition."""
    parent = fork.transitions_from()
    assert parent is not None, "Parent fork must be defined for this test"

    code_size = parent.max_code_size()
    deploy_code = Op.JUMPDEST * code_size
    initcode = Initcode(deploy_code=deploy_code)

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

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

    blocks = [
        Block(
            timestamp=14_999,
            txs=[
                Transaction(
                    sender=alice,
                    to=None,
                    data=initcode,
                )
            ],
        ),
        Block(
            timestamp=15_000,
            txs=[
                Transaction(
                    sender=bob,
                    to=None,
                    data=initcode,
                )
            ],
        ),
    ]

    post: dict[Any, Account | None] = {
        create_address_pre: Account(code=deploy_code),
        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.