Skip to content

test_invalid_blob_gas_used_in_header()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_blob_gas_used_in_header@343274cc.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_blob_gas_used_in_header --fork Amsterdam

Test rejection of blocks where the blobGasUsed in the header is invalid.

  • blobGasUsed is not equal to the number of data blobs in the block
  • blobGasUsed is the max uint64 value
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
@pytest.mark.parametrize_by_fork(
    "new_blobs,header_blob_gas_used",
    all_invalid_blob_gas_used_combinations,
)
@pytest.mark.parametrize("parent_blobs", [0])
@pytest.mark.exception_test
@pytest.mark.slow()
def test_invalid_blob_gas_used_in_header(
    blockchain_test: BlockchainTestFiller,
    env: Environment,
    pre: Mapping[Address, Account],
    blocks: List[Block],
    new_blobs: int,
    header_blob_gas_used: Optional[int],
    blob_gas_per_blob: int,
) -> None:
    """
    Test rejection of blocks where the `blobGasUsed` in the header is invalid.

    - `blobGasUsed` is not equal to the number of data blobs in the block
    - `blobGasUsed` is the max uint64 value
    """
    if header_blob_gas_used is None:
        raise Exception("test case is badly formatted")

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

Parametrized Test Cases

This test generates 484 parametrized test cases across 4 forks.