Skip to content

Commit

Permalink
tests/cancun/eip4844_blobs: Update Engine API error codes for invalid…
Browse files Browse the repository at this point in the history
… tests.
  • Loading branch information
--global committed Aug 10, 2023
1 parent 8ddd74b commit 99c58db
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
36 changes: 31 additions & 5 deletions tests/cancun/eip4844_blobs/test_blob_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@

import pytest

from ethereum_test_tools import Account, Block, BlockchainTestFiller, Environment, Header
from ethereum_test_tools import (
Account,
Block,
BlockchainTestFiller,
EngineAPIError,
Environment,
Header,
)
from ethereum_test_tools import Opcodes as Op
from ethereum_test_tools import (
Storage,
Expand Down Expand Up @@ -312,10 +319,20 @@ def env(
)


@pytest.fixture
def engine_api_error_code() -> Optional[int]:
"""
Expected Engine API error code to be returned by the client on consumption
of the erroneous block in hive.
"""
return None


@pytest.fixture
def blocks(
txs: List[Transaction],
tx_error: Optional[str],
engine_api_error_code: Optional[int],
) -> List[Block]:
"""
Prepare the list of blocks for all test cases.
Expand All @@ -333,7 +350,12 @@ def blocks(
* Spec.GAS_PER_BLOB
)
return [
Block(txs=txs, exception=tx_error, rlp_modifier=Header(blob_gas_used=header_blob_gas_used))
Block(
txs=txs,
exception=tx_error,
engine_api_error_code=engine_api_error_code,
rlp_modifier=Header(blob_gas_used=header_blob_gas_used),
)
]


Expand Down Expand Up @@ -925,10 +947,11 @@ def test_blob_tx_attribute_gasprice_opcode(
"parent_excess_blobs",
"tx_max_fee_per_blob_gas",
"tx_error",
"engine_api_error_code",
],
[
([0], None, 1, "tx_type_3_not_allowed_yet"),
([1], None, 1, "tx_type_3_not_allowed_yet"),
([0], None, 1, "Invalid params", EngineAPIError.InvalidParams),
([1], None, 1, "Invalid params", EngineAPIError.InvalidParams),
],
ids=["no_blob_tx", "one_blob_tx"],
)
Expand All @@ -939,7 +962,10 @@ def test_blob_type_tx_pre_fork(
blocks: List[Block],
):
"""
Reject blocks with blob type transactions before Cancun fork
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 rejected with the `-32602: Invalid params` error.
"""
blockchain_test(
pre=pre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def test_invalid_pre_fork_block_with_blob_fields(
"""
Test block rejection when `excessBlobGas` and/or `blobGasUsed` fields are present on a pre-fork
block.
Blocks sent by NewPayloadV2 (Shanghai) that contain `excessBlobGas` and `blobGasUsed` fields
must be rejected with the `-32602: Invalid params` error.
"""
header_modifier = Header()
if excess_blob_gas_present:
Expand Down Expand Up @@ -193,6 +196,9 @@ def test_invalid_post_fork_block_without_blob_fields(
"""
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 `-32602: Invalid params` error.
"""
header_modifier = Header()
if excess_blob_gas_missing:
Expand Down

0 comments on commit 99c58db

Please sign in to comment.