Skip to content

test_invalid_blob_tx_contract_creation()

Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py::test_invalid_blob_tx_contract_creation@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip4844_blobs/test_blob_txs.py::test_invalid_blob_tx_contract_creation --fork Amsterdam

Reject blocks that include blob transactions that have nil to value (contract creating).

Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
@pytest.mark.inclusion_test
@pytest.mark.parametrize(
    "tx_gas", [500_000], ids=[""]
)  # Increase gas to account for contract creation
@pytest.mark.exception_test
@pytest.mark.valid_from("Cancun")
def test_invalid_blob_tx_contract_creation(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    env: Environment,
    txs: List[Transaction],
    header_verify: Optional[Header],
) -> None:
    """
    Reject blocks that include blob transactions that have nil to value
    (contract creating).
    """
    assert len(txs) == 1
    assert (
        txs[0].blob_versioned_hashes is not None
        and len(txs[0].blob_versioned_hashes) == 1
    )
    # Replace the transaction with a contract creating one, only in the RLP
    # version
    contract_creating_tx = txs[0].copy(to=None).with_signature_and_sender()
    txs[0].rlp_override = contract_creating_tx.rlp()
    blockchain_test(
        pre=pre,
        post={},
        blocks=[
            Block(
                txs=txs,
                exception=[
                    BlockException.RLP_STRUCTURES_ENCODING,
                    TransactionException.TYPE_3_TX_CONTRACT_CREATION,
                ],
                header_verify=header_verify,
                # Skipped due to the T8N not receiving the invalid transaction,
                # instead we are passing a valid transaction to T8N and then
                # the transaction is replaced directly in the block RLP.
                skip_exception_verification=True,
            )
        ],
        genesis_environment=env,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 4 forks.