Skip to content

test_bal_withdrawal_empty_block()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_withdrawal_empty_block@892e6d1e.

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_withdrawal_empty_block --fork Amsterdam

Ensure BAL captures withdrawal balance changes in empty block.

Charlie starts with 1 gwei balance (existing account). Block with 0 transactions and 1 withdrawal of 10 gwei to Charlie. Charlie ends with 11 gwei balance.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def test_bal_withdrawal_empty_block(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure BAL captures withdrawal balance changes in empty block.

    Charlie starts with 1 gwei balance (existing account).
    Block with 0 transactions and 1 withdrawal of 10 gwei to Charlie.
    Charlie ends with 11 gwei balance.
    """
    charlie = pre.fund_eoa(amount=1 * GWEI)

    block = Block(
        txs=[],
        withdrawals=[
            Withdrawal(
                index=0,
                validator_index=0,
                address=charlie,
                amount=10,
            )
        ],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                charlie: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(
                            block_access_index=1, post_balance=11 * GWEI
                        )
                    ],
                ),
            }
        ),
    )

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.