Skip to content

test_many_withdrawals()

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

Generate fixtures for these test cases for Shanghai with:

Shanghai only:

fill -v tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_many_withdrawals --fork=Shanghai --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Shanghai:

fill -v tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_many_withdrawals --until=Shanghai

Test Withdrawals with a count of N withdrawals in a single block where N is a high number not expected to be seen in mainnet.

Source code in tests/shanghai/eip4895_withdrawals/test_withdrawals.py
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
def test_many_withdrawals(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
):
    """
    Test Withdrawals with a count of N withdrawals in a single block where
    N is a high number not expected to be seen in mainnet.
    """
    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)