Skip to content

test_bal_withdrawal_to_precompiles()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_withdrawal_to_precompiles@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_to_precompiles --fork Amsterdam

Ensure BAL captures withdrawal to precompile addresses.

Block with 0 transactions and 1 withdrawal of 10 gwei to precompile. Precompile ends with 10 gwei balance.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
@pytest.mark.parametrize_by_fork(
    "precompile",
    lambda fork: [
        pytest.param(addr, id=f"0x{int.from_bytes(addr, 'big'):02x}")
        for addr in fork.precompiles()
    ],
)
def test_bal_withdrawal_to_precompiles(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    precompile: Address,
) -> None:
    """
    Ensure BAL captures withdrawal to precompile addresses.

    Block with 0 transactions and 1 withdrawal of 10 gwei to precompile.
    Precompile ends with 10 gwei balance.
    """
    block = Block(
        txs=[],
        withdrawals=[
            Withdrawal(
                index=0,
                validator_index=0,
                address=precompile,
                amount=10,
            )
        ],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                precompile: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(
                            block_access_index=1, post_balance=10 * GWEI
                        )
                    ],
                    storage_reads=[],
                    storage_changes=[],
                ),
            }
        ),
    )

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

Parametrized Test Cases

This test generates 18 parametrized test cases across 1 fork.