Skip to content

test_blob_type_tx_pre_fork()

Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_type_tx_pre_fork@20373115.

Generate fixtures for these test cases for Cancun with:

fill -v tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_type_tx_pre_fork --fork Cancun

Reject blocks with blob type transactions before Cancun fork.

Blocks sent by NewPayloadV2 (Shanghai) that contain blob type transactions, furthermore blobs field within NewPayloadV2 method must be computed as INVALID, due to an invalid block hash.

Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
@pytest.mark.parametrize(
    [
        "blobs_per_tx",
        "parent_excess_blobs",
        "tx_max_fee_per_blob_gas",
        "tx_error",
        "block_error",
    ],
    [
        (
            [0],
            None,
            1,
            [
                TransactionException.TYPE_3_TX_PRE_FORK,
                TransactionException.TYPE_3_TX_ZERO_BLOBS,
            ],
            [
                TransactionException.TYPE_3_TX_PRE_FORK,
                TransactionException.TYPE_3_TX_ZERO_BLOBS,
            ],
        ),
        (
            [1],
            None,
            1,
            TransactionException.TYPE_3_TX_PRE_FORK,
            [
                TransactionException.TYPE_3_TX_PRE_FORK,
                BlockException.INVALID_VERSIONED_HASHES,
            ],
        ),
    ],
    ids=["no_blob_tx", "one_blob_tx"],
)
@pytest.mark.exception_test
@pytest.mark.valid_at_transition_to("Cancun")
@pytest.mark.slow()
def test_blob_type_tx_pre_fork(
    state_test: StateTestFiller,
    pre: Alloc,
    txs: List[Transaction],
    block_error: Optional[TransactionException | BlockException],
) -> None:
    """
    Reject blocks with blob type transactions before Cancun fork.

    Blocks sent by NewPayloadV2 (Shanghai) that contain blob type transactions,
    furthermore blobs field within NewPayloadV2 method must be computed as
    INVALID, due to an invalid block hash.
    """
    assert len(txs) == 1
    state_test(
        pre=pre,
        post={},
        tx=txs[0],
        env=Environment(),  # `env` fixture has blob fields
        block_exception=block_error,
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.