Skip to content

test_many_withdrawals()

Documentation for tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_many_withdrawals@5f132e7c.

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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
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.