Skip to content

test_invalid_max_blobs_per_tx()

Documentation for tests/osaka/eip7594_peerdas/test_max_blob_per_tx.py::test_invalid_max_blobs_per_tx@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/osaka/eip7594_peerdas/test_max_blob_per_tx.py::test_invalid_max_blobs_per_tx --fork Amsterdam

Test that transactions exceeding MAX_BLOBS_PER_TX are rejected. Verifies that individual transactions cannot contain more than the maximum allowed number of blobs per transaction, even if the total would be within the block limit.

Source code in tests/osaka/eip7594_peerdas/test_max_blob_per_tx.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@pytest.mark.parametrize_by_fork(
    "blob_count",
    lambda fork: [
        fork.max_blobs_per_tx() + 1,
        fork.max_blobs_per_tx() + 2,
        fork.max_blobs_per_block(),
        fork.max_blobs_per_block() + 1,
    ],
)
@pytest.mark.valid_from("Osaka")
@pytest.mark.exception_test
def test_invalid_max_blobs_per_tx(
    fork: Fork,
    state_test: StateTestFiller,
    pre: Alloc,
    env: Environment,
    tx: Transaction,
    blob_count: int,
) -> None:
    """
    Test that transactions exceeding MAX_BLOBS_PER_TX are rejected. Verifies
    that individual transactions cannot contain more than the maximum allowed
    number of blobs per transaction, even if the total would be within the
    block limit.
    """
    # When the blob count also exceeds the block allowance, the reported
    # exception depends on the fork's validation order, so accept either.
    state_test(
        env=env,
        pre=pre,
        tx=tx.with_error(
            [
                TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED,
                TransactionException.TYPE_3_TX_BLOB_COUNT_EXCEEDED,
            ]
            if blob_count > fork.max_blobs_per_block()
            else TransactionException.TYPE_3_TX_BLOB_COUNT_EXCEEDED
        ),
        post={},
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 2 forks.