Skip to content

Commit 25c2d13

Browse files
committed
feat(consume): add initial implementation of consume enginex
Also removes a file that was unintentionally added in #1718.
1 parent 273d7a8 commit 25c2d13

File tree

15 files changed

+703
-40
lines changed

15 files changed

+703
-40
lines changed

src/cli/pytest_commands/consume.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ def get_command_logic_test_paths(command_name: str, is_hive: bool) -> List[Path]
4444
command_logic_test_paths = [
4545
base_path / "simulators" / "simulator_logic" / f"test_via_{cmd}.py" for cmd in commands
4646
]
47-
elif command_name in ["engine", "rlp"]:
47+
elif command_name in ["engine", "enginex"]:
4848
command_logic_test_paths = [
49-
base_path / "simulators" / "simulator_logic" / f"test_via_{command_name}.py"
49+
base_path / "simulators" / "simulator_logic" / "test_via_engine.py"
50+
]
51+
elif command_name == "rlp":
52+
command_logic_test_paths = [
53+
base_path / "simulators" / "simulator_logic" / "test_via_rlp.py"
5054
]
5155
elif command_name == "direct":
5256
command_logic_test_paths = [base_path / "direct" / "test_via_direct.py"]
@@ -103,13 +107,19 @@ def rlp() -> None:
103107

104108
@consume_command(is_hive=True)
105109
def engine() -> None:
106-
"""Client consumes via the Engine API."""
110+
"""Client consumes Engine Fixtures via the Engine API."""
111+
pass
112+
113+
114+
@consume_command(is_hive=True)
115+
def enginex() -> None:
116+
"""Client consumes Engine X Fixtures via the Engine API."""
107117
pass
108118

109119

110120
@consume_command(is_hive=True)
111121
def hive() -> None:
112-
"""Client consumes via all available hive methods (rlp, engine)."""
122+
"""Client consumes via rlp & engine hive methods."""
113123
pass
114124

115125

src/cli/pytest_commands/processors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def process_args(self, args: List[str]) -> List[str]:
101101

102102
if self.command_name == "engine":
103103
modified_args.extend(["-p", "pytest_plugins.consume.simulators.engine.conftest"])
104+
elif self.command_name == "enginex":
105+
modified_args.extend(["-p", "pytest_plugins.consume.simulators.enginex.conftest"])
106+
if (
107+
self._has_parallelism_flag(args) or "-n" in modified_args
108+
) and "--dist" not in modified_args:
109+
modified_args.extend(["--dist=loadgroup"])
104110
elif self.command_name == "rlp":
105111
modified_args.extend(["-p", "pytest_plugins.consume.simulators.rlp.conftest"])
106112
else:

src/pytest_plugins/consume/consume.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,18 @@ def pytest_generate_tests(metafunc):
495495
if test_case.format.format_name not in metafunc.config._supported_fixture_formats:
496496
continue
497497
fork_markers = get_relative_fork_markers(test_case.fork, strict_mode=False)
498+
499+
# Append pre_hash (first 8 chars) to test ID for easier selection with --sim.limit
500+
test_id = test_case.id
501+
if hasattr(test_case, "pre_hash") and test_case.pre_hash:
502+
test_id = f"{test_case.id}[{test_case.pre_hash[:8]}]"
503+
498504
param = pytest.param(
499505
test_case,
500-
id=test_case.id,
506+
id=test_id,
501507
marks=[getattr(pytest.mark, m) for m in fork_markers]
502-
+ [getattr(pytest.mark, test_case.format.format_name)],
508+
+ [getattr(pytest.mark, test_case.format.format_name)]
509+
+ [pytest.mark.xdist_group(name=test_case.pre_hash)],
503510
)
504511
param_list.append(param)
505512

src/pytest_plugins/consume/hive_engine_test/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/pytest_plugins/consume/hive_simulators_reorg/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Consume Engine test functions."""
1+
"""The consume engine simulator."""

src/pytest_plugins/consume/simulators/engine/conftest.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
"""
2-
Pytest fixtures for the `consume engine` simulator.
3-
4-
Configures the hive back-end & EL clients for each individual test execution.
5-
"""
1+
"""Pytest plugin for the `consume engine` simulator."""
62

73
import io
84
from typing import Mapping
@@ -29,6 +25,18 @@ def pytest_configure(config):
2925
config._supported_fixture_formats = [BlockchainEngineFixture.format_name]
3026

3127

28+
@pytest.fixture(scope="module")
29+
def test_suite_name() -> str:
30+
"""The name of the hive test suite used in this simulator."""
31+
return "eest/consume-engine"
32+
33+
34+
@pytest.fixture(scope="module")
35+
def test_suite_description() -> str:
36+
"""The description of the hive test suite used in this simulator."""
37+
return "Execute blockchain tests against clients using the Engine API."
38+
39+
3240
@pytest.fixture(scope="function")
3341
def engine_rpc(client: Client, client_exception_mapper: ExceptionMapper | None) -> EngineRPC:
3442
"""Initialize engine RPC client for the execution client under test."""
@@ -42,18 +50,6 @@ def engine_rpc(client: Client, client_exception_mapper: ExceptionMapper | None)
4250
return EngineRPC(f"http://{client.ip}:8551")
4351

4452

45-
@pytest.fixture(scope="module")
46-
def test_suite_name() -> str:
47-
"""The name of the hive test suite used in this simulator."""
48-
return "eest/consume-engine"
49-
50-
51-
@pytest.fixture(scope="module")
52-
def test_suite_description() -> str:
53-
"""The description of the hive test suite used in this simulator."""
54-
return "Execute blockchain tests against clients using the Engine API."
55-
56-
5753
@pytest.fixture(scope="function")
5854
def client_files(buffered_genesis: io.BufferedReader) -> Mapping[str, io.BufferedReader]:
5955
"""Define the files that hive will start the client with."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""The consume enginex simulator."""
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Pytest fixtures for the `consume enginex` simulator.
3+
4+
Configures the hive back-end & EL clients for test execution with BlockchainEngineXFixtures.
5+
"""
6+
7+
import pytest
8+
from hive.client import Client
9+
10+
from ethereum_test_exceptions import ExceptionMapper
11+
from ethereum_test_fixtures import BlockchainEngineXFixture
12+
from ethereum_test_rpc import EngineRPC
13+
14+
pytest_plugins = (
15+
"pytest_plugins.pytest_hive.pytest_hive",
16+
"pytest_plugins.consume.simulators.base",
17+
"pytest_plugins.consume.simulators.multi_test_client",
18+
"pytest_plugins.consume.simulators.test_case_description",
19+
"pytest_plugins.consume.simulators.timing_data",
20+
"pytest_plugins.consume.simulators.exceptions",
21+
)
22+
23+
24+
def pytest_configure(config):
25+
"""Set the supported fixture formats for the engine simulator."""
26+
config._supported_fixture_formats = [BlockchainEngineXFixture.format_name]
27+
28+
29+
@pytest.fixture(scope="module")
30+
def test_suite_name() -> str:
31+
"""The name of the hive test suite used in this simulator."""
32+
return "eest/consume-enginex"
33+
34+
35+
@pytest.fixture(scope="module")
36+
def test_suite_description() -> str:
37+
"""The description of the hive test suite used in this simulator."""
38+
return (
39+
"Execute blockchain tests against clients using the Engine API with "
40+
"pre-allocation group optimization using Engine X fixtures."
41+
)
42+
43+
44+
@pytest.fixture(scope="function")
45+
def engine_rpc(client: Client, client_exception_mapper: ExceptionMapper | None) -> EngineRPC:
46+
"""Initialize engine RPC client for the execution client under test."""
47+
if client_exception_mapper:
48+
return EngineRPC(
49+
f"http://{client.ip}:8551",
50+
response_validation_context={
51+
"exception_mapper": client_exception_mapper,
52+
},
53+
)
54+
return EngineRPC(f"http://{client.ip}:8551")

0 commit comments

Comments
 (0)