Skip to content

test_withdrawing_to_precompiles()

Documentation for tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles@ffe48572.

Generate fixtures for these test cases for Bogota with:

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

Test withdrawing to all precompiles for a given fork.

Source code in tests/shanghai/eip4895_withdrawals/test_withdrawals.py
@pytest.mark.xdist_group(name="bigmem")
@pytest.mark.parametrize("amount", [0, 1])
@pytest.mark.with_all_precompiles
@pytest.mark.slow()
def test_withdrawing_to_precompiles(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    precompile: int,
    amount: int,
) -> None:
    """Test withdrawing to all precompiles for a given fork."""
    sender = pre.fund_eoa()
    post: Dict = {}

    blocks = [
        # First block performs the withdrawal
        Block(
            withdrawals=[
                Withdrawal(
                    index=0,
                    validator_index=0,
                    address=Address(precompile),
                    amount=amount,
                )
            ]
        ),
        # Second block sends a transaction to the precompile
        Block(
            txs=[
                Transaction(
                    sender=sender,
                    gas_limit=100000,
                    to=Address(precompile),
                ),
            ],
        ),
    ]
    blockchain_test(pre=pre, post=post, blocks=blocks)

Parametrized Test Cases

This test generates 36 parametrized test cases across 6 forks.