Skip to content

test_invalid_header()

Documentation for tests/london/validation/test_header.py::test_invalid_header@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/london/validation/test_header.py::test_invalid_header --fork Amsterdam

Tests that a block with an invalid header (e.g. base_fee_per_gas) is rejected.

Source code in tests/london/validation/test_header.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@pytest.mark.valid_from("London")
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "field,invalid_value,exception",
    [
        ("base_fee_per_gas", 1, BlockException.INVALID_BASEFEE_PER_GAS),
    ],
)
def test_invalid_header(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    field: str,
    invalid_value: int,
    exception: BlockException | list[BlockException],
) -> None:
    """
    Tests that a block with an invalid header (e.g. base_fee_per_gas) is
    rejected.
    """
    invalid_fields = {field: invalid_value}

    block = Block(
        txs=[], rlp_modifier=Header(**invalid_fields), exception=exception
    )

    blockchain_test(pre=pre, post={}, blocks=[block])

Parametrized Test Cases

This test generates 1 parametrized test case across 7 forks.