|
7 | 7 |
|
8 | 8 | from ethereum_test_fixtures import BlockchainEngineFixture |
9 | 9 | from ethereum_test_rpc import EngineRPC, EthRPC |
10 | | -from ethereum_test_rpc.types import ForkchoiceState, PayloadStatusEnum |
| 10 | +from ethereum_test_rpc.types import ForkchoiceState, JSONRPCError, PayloadStatusEnum |
11 | 11 | from pytest_plugins.consume.hive_simulators.exceptions import GenesisBlockMismatchExceptionError |
12 | 12 |
|
13 | 13 | from ...decorator import fixture_format |
@@ -52,13 +52,24 @@ def test_via_engine( |
52 | 52 | for i, payload in enumerate(blockchain_fixture.payloads): |
53 | 53 | with total_payload_timing.time(f"Payload {i + 1}") as payload_timing: |
54 | 54 | with payload_timing.time(f"engine_newPayloadV{payload.new_payload_version}"): |
55 | | - payload_response = engine_rpc.new_payload( |
56 | | - *payload.params, |
57 | | - version=payload.new_payload_version, |
58 | | - ) |
59 | | - assert payload_response.status == ( |
60 | | - PayloadStatusEnum.VALID if payload.valid() else PayloadStatusEnum.INVALID |
61 | | - ), f"unexpected status: {payload_response}" |
| 55 | + try: |
| 56 | + payload_response = engine_rpc.new_payload( |
| 57 | + *payload.params, |
| 58 | + version=payload.new_payload_version, |
| 59 | + ) |
| 60 | + assert payload_response.status == ( |
| 61 | + PayloadStatusEnum.VALID |
| 62 | + if payload.valid() |
| 63 | + else PayloadStatusEnum.INVALID |
| 64 | + ), f"unexpected status: {payload_response}" |
| 65 | + except JSONRPCError as e: |
| 66 | + if payload.error_code is None: |
| 67 | + raise Exception(f"unexpected error: {e.code} - {e.message}") from e |
| 68 | + if e.code != payload.error_code: |
| 69 | + raise Exception( |
| 70 | + f"unexpected error code: {e.code}, expected: {payload.error_code}" |
| 71 | + ) from e |
| 72 | + |
62 | 73 | if payload.valid(): |
63 | 74 | with payload_timing.time( |
64 | 75 | f"engine_forkchoiceUpdatedV{payload.forkchoice_updated_version}" |
|
0 commit comments