Skip to content

test_deposit_negative()

Documentation for tests/prague/eip6110_deposits/test_deposits.py::test_deposit_negative@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/prague/eip6110_deposits/test_deposits.py::test_deposit_negative --fork Bogota

Test producing a block with the incorrect deposits in the body of the block, and/or Engine API payload.

Source code in tests/prague/eip6110_deposits/test_deposits.py
@pytest.mark.parametrize(
    "requests,block_body_override_requests,exception",
    [
        pytest.param(
            [],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                ),
            ],
            BlockException.INVALID_REQUESTS,
            id="no_deposits_non_empty_requests_list",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_empty_requests_list",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x02,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                )
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_pubkey_mismatch",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x03,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                )
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_credentials_mismatch",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=2_000_000_000,
                    signature=0x03,
                    index=0x0,
                )
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_amount_mismatch",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x04,
                    index=0x0,
                )
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_signature_mismatch",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x1,
                )
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_index_mismatch",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        ),
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x1,
                        ),
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x1,
                ),
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                ),
            ],
            BlockException.INVALID_REQUESTS,
            id="two_deposits_out_of_order",
        ),
        pytest.param(
            [
                SystemContractInteractionTransaction(
                    requests=[
                        DepositRequest(
                            pubkey=0x01,
                            withdrawal_credentials=0x02,
                            amount=1_000_000_000,
                            signature=0x03,
                            index=0x0,
                        )
                    ],
                ),
            ],
            [
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                ),
                DepositRequest(
                    pubkey=0x01,
                    withdrawal_credentials=0x02,
                    amount=1_000_000_000,
                    signature=0x03,
                    index=0x0,
                ),
            ],
            BlockException.INVALID_REQUESTS,
            id="single_deposit_duplicate_in_requests_list",
        ),
    ],
)
@pytest.mark.exception_test
def test_deposit_negative(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    blocks: List[Block],
) -> None:
    """
    Test producing a block with the incorrect deposits in the body of the
    block, and/or Engine API payload.
    """
    blockchain_test(
        pre=pre,
        post={},
        blocks=blocks,
    )

Parametrized Test Cases

This test generates 9 parametrized test cases across 4 forks.