Skip to content

test_gas_limit_below_minimum()

Documentation for tests/frontier/validation/test_header.py::test_gas_limit_below_minimum@7b8124a7.

Generate fixtures for these test cases for Osaka with:

fill -v tests/frontier/validation/test_header.py::test_gas_limit_below_minimum --fork Osaka

Tests that a block with a gas limit below the minimum throws an error.

Source code in tests/frontier/validation/test_header.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@pytest.mark.parametrize(
    "gas_limit",
    [
        pytest.param(0, marks=pytest.mark.exception_test),
        pytest.param(1, marks=pytest.mark.exception_test),
        pytest.param(4999, marks=pytest.mark.exception_test),
        5000,
    ],
)
def test_gas_limit_below_minimum(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    gas_limit: int,
    env: Environment,
) -> None:
    """
    Tests that a block with a gas limit below the minimum throws an error.
    """
    modified_fields = {"gas_limit": gas_limit}
    env.gas_limit = ZeroPaddedHexNumber(5000)

    block = Block(
        txs=[],
        rlp_modifier=Header(**modified_fields),
        exception=BlockException.INVALID_GASLIMIT
        if gas_limit < 5000
        else None,
    )

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

Parametrized Test Cases

This test generates 4 parametrized test cases across 13 forks.