Skip to content

test_invalid_excess_blob_gas_change()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_excess_blob_gas_change@2867859a.

Generate fixtures for these test cases for Amsterdam with:

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

Test rejection of blocks where the excessBlobGas changes to an invalid value.

Given a parent block containing [0, MAX_BLOBS_PER_BLOCK] blobs, test an invalid excessBlobGas value by changing it by [-TARGET_BLOBS_PER_BLOCK, TARGET_BLOBS_PER_BLOCK] from the correct value.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
@pytest.mark.parametrize_by_fork(
    "parent_blobs,header_excess_blobs_delta",
    lambda fork: itertools.product(
        # parent_blobs
        range(0, fork.max_blobs_per_block() + 1),
        # header_excess_blobs_delta (from correct value)
        [
            x
            for x in range(
                -fork.target_blobs_per_block(),
                fork.target_blobs_per_block() + 1,
            )
            if x != 0
        ],
    ),
)
@pytest.mark.parametrize("new_blobs", [1])
@pytest.mark.exception_test
def test_invalid_excess_blob_gas_change(
    blockchain_test: BlockchainTestFiller,
    env: Environment,
    pre: Mapping[Address, Account],
    blocks: List[Block],
    correct_excess_blob_gas: int,
    header_excess_blob_gas: Optional[int],
) -> None:
    """
    Test rejection of blocks where the `excessBlobGas` changes to an invalid
    value.

    Given a parent block containing `[0, MAX_BLOBS_PER_BLOCK]` blobs, test an
    invalid `excessBlobGas` value by changing it by `[-TARGET_BLOBS_PER_BLOCK,
    TARGET_BLOBS_PER_BLOCK]` from the correct value.
    """
    if header_excess_blob_gas is None:
        raise Exception("test case is badly formatted")

    if header_excess_blob_gas == correct_excess_blob_gas:
        raise Exception("invalid test case")

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

Parametrized Test Cases

This test generates 616 parametrized test cases across 4 forks.