Skip to content

test_invalid_post_fork_block_without_blob_fields()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py::test_invalid_post_fork_block_without_blob_fields@892e6d1e.

Generate fixtures for these test cases for Cancun with:

fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py::test_invalid_post_fork_block_without_blob_fields --fork Cancun

Test block rejection when excessBlobGas and/or blobGasUsed fields are missing on a post-fork block.

Blocks sent by NewPayloadV3 (Cancun) without excessBlobGas and blobGasUsed fields must be rejected with the appropriate EngineAPIError.InvalidParams error.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
@pytest.mark.valid_at_transition_to("Cancun", subsequent_forks=False)
@pytest.mark.parametrize(
    "excess_blob_gas_missing,blob_gas_used_missing",
    [
        (True, False),
        (False, True),
        (True, True),
    ],
)
@pytest.mark.exception_test
def test_invalid_post_fork_block_without_blob_fields(
    blockchain_test: BlockchainTestFiller,
    genesis_environment: Environment,
    pre: Alloc,
    pre_fork_blocks: List[Block],
    excess_blob_gas_missing: bool,
    blob_gas_used_missing: bool,
) -> None:
    """
    Test block rejection when `excessBlobGas` and/or `blobGasUsed` fields are
    missing on a post-fork block.

    Blocks sent by NewPayloadV3 (Cancun) without `excessBlobGas` and
    `blobGasUsed` fields must be rejected with the appropriate
    `EngineAPIError.InvalidParams` error.
    """
    header_modifier = Header()
    if excess_blob_gas_missing:
        header_modifier.excess_blob_gas = Header.REMOVE_FIELD
    if blob_gas_used_missing:
        header_modifier.blob_gas_used = Header.REMOVE_FIELD
    blockchain_test(
        pre=pre,
        post={},
        blocks=pre_fork_blocks
        + [
            Block(
                timestamp=FORK_TIMESTAMP,
                rlp_modifier=header_modifier,
                exception=BlockException.INCORRECT_BLOCK_FORMAT,
                engine_api_error_code=EngineAPIError.InvalidParams,
            )
        ],
        genesis_environment=genesis_environment,
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 1 fork.