Skip to content

test_many_withdrawals()

Documentation for tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_many_withdrawals@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_many_withdrawals --fork Amsterdam

Test an unexpected high number of withdrawals in a single block.

Source code in tests/shanghai/eip4895_withdrawals/test_withdrawals.py
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
403
404
405
406
407
408
409
def test_many_withdrawals(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test an unexpected high number of withdrawals in a single block.
    """
    n = 400
    withdrawals = []
    post = {}
    for i in range(n):
        addr = pre.deploy_contract(Op.SSTORE(Op.NUMBER, 1))
        amount = i * 1
        withdrawals.append(
            Withdrawal(
                index=i,
                validator_index=i,
                address=addr,
                amount=amount,
            )
        )
        post[addr] = Account(
            code=Op.SSTORE(Op.NUMBER, 1),
            balance=amount * ONE_GWEI,
            storage={},
        )

    blocks = [
        Block(
            withdrawals=withdrawals,
        ),
    ]

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

Parametrized Test Cases

This test generates 1 parametrized test case across 5 forks.