Skip to content

test_large_amount()

Documentation for tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_large_amount@02aafd78.

Generate fixtures for these test cases for Bogota with:

fill -v tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_large_amount --fork Bogota

Test withdrawals that have a large gwei amount.

Test such that that (gwei * 1e9) could overflow uint64 but not uint256.

Source code in tests/shanghai/eip4895_withdrawals/test_withdrawals.py
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
@pytest.mark.xdist_group(name="bigmem")
def test_large_amount(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test withdrawals that have a large gwei amount.

    Test such that that (gwei * 1e9) could overflow uint64 but not uint256.
    """
    withdrawals: List[Withdrawal] = []
    amounts: List[int] = [
        (2**35),
        (2**64) - 1,
        (2**63) + 1,
        (2**63),
        (2**63) - 1,
    ]

    post = {}

    for i, amount in enumerate(amounts):
        addr = pre.fund_eoa(0)
        withdrawals.append(
            Withdrawal(
                index=i,
                validator_index=i,
                address=addr,
                amount=amount,
            )
        )
        post[addr] = Account(balance=(amount * ONE_GWEI))

    blocks = [
        Block(
            withdrawals=withdrawals,
        )
    ]
    blockchain_test(pre=pre, post=post, blocks=blocks)

Parametrized Test Cases

This test generates 1 parametrized test case across 6 forks.