Skip to content

test_bal_multiple_withdrawals_same_address()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_multiple_withdrawals_same_address@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_multiple_withdrawals_same_address --fork Amsterdam

Ensure BAL accumulates multiple withdrawals to same address.

Charlie starts with 0 balance. Block empty block with 3 withdrawals to Charlie: 5 gwei, 10 gwei, 15 gwei. Charlie ends with 30 gwei balance (cumulative).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py
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
424
425
426
427
428
429
430
def test_bal_multiple_withdrawals_same_address(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure BAL accumulates multiple withdrawals to same address.

    Charlie starts with 0 balance.
    Block empty block with 3 withdrawals to Charlie: 5 gwei, 10 gwei, 15 gwei.
    Charlie ends with 30 gwei balance (cumulative).
    """
    charlie = pre.fund_eoa(amount=0)

    block = Block(
        txs=[],
        withdrawals=[
            Withdrawal(index=i, validator_index=i, address=charlie, amount=amt)
            for i, amt in enumerate([5, 10, 15])
        ],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                charlie: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(
                            block_access_index=1, post_balance=30 * GWEI
                        )
                    ],
                ),
            }
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            charlie: Account(balance=30 * GWEI),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.