Skip to content

test_max_initcode_size_fork_transition()

Documentation for tests/amsterdam/eip7954_increase_max_contract_size/test_fork_transition.py::test_max_initcode_size_fork_transition@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

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

Ensure the new max initcode size limit activates exactly at the fork.

Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_fork_transition.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@pytest.mark.exception_test
def test_max_initcode_size_fork_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: TransitionFork,
) -> None:
    """Ensure the new max initcode size limit activates exactly at the fork."""
    initcode = Initcode(
        deploy_code=Op.STOP,
        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 = [
        # Pre-fork: initcode at the new max exceeds the parent fork's limit,
        # so the tx is rejected and the block is invalid.
        Block(
            timestamp=14_999,
            txs=[
                Transaction(
                    sender=alice,
                    to=None,
                    data=initcode,
                    error=initcode_too_large,
                )
            ],
            exception=initcode_too_large,
        ),
        # Post-fork: the new limit is in effect, tx succeeds.
        Block(
            timestamp=15_000,
            txs=[
                Transaction(
                    sender=bob,
                    to=None,
                    data=initcode,
                )
            ],
        ),
    ]

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

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.