Skip to content

Commit

Permalink
feat(plugins/consume): Check port 8551 on Engine API tests (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz authored Jan 21, 2025
1 parent 7e5ecfa commit 2600598
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Release tarball changes:
- 🐞 fix(consume): allow absolute paths with `--evm-bin` ([#1052](https://github.com/ethereum/execution-spec-tests/pull/1052)).
- ✨ Disable EIP-7742 framework changes for Prague ([#1023](https://github.com/ethereum/execution-spec-tests/pull/1023)).
- ✨ Allow verification of the transaction receipt on executed test transactions ([#1068](https://github.com/ethereum/execution-spec-tests/pull/1068)).
- 🐞 fix(consume): use `"HIVE_CHECK_LIVE_PORT"` to signal hive to wait for port 8551 (Engine API port) instead of the 8545 port when running `consume engine` ([#1095](https://github.com/ethereum/execution-spec-tests/pull/1095)).

### 🔧 EVM Tools

Expand Down
38 changes: 23 additions & 15 deletions src/pytest_plugins/consume/hive_simulators/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io
import json
from typing import Generator, List, cast
from typing import Generator, List, Literal, cast

import pytest
import rich
Expand Down Expand Up @@ -64,8 +64,7 @@ def eest_consume_commands(
hive_dev = f"./hive --dev --client-file configs/prague.yaml --client {client_type.name}"
input_source = request.config.getoption("fixture_source")
consume = (
f'consume {test_suite_name.split("-")[-1]} -v --input={input_source} -k '
f'"{test_case.id}"'
f'consume {test_suite_name.split("-")[-1]} -v --input={input_source} -k "{test_case.id}"'
)
return [hive_dev, consume]

Expand All @@ -89,13 +88,13 @@ def test_case_description(
else:
description += f"\n\n{blockchain_fixture.info['description']}"
description += (
f"\n\nCommand to reproduce entirely in hive:" f"\n<code>{hive_consume_command}</code>"
f"\n\nCommand to reproduce entirely in hive:\n<code>{hive_consume_command}</code>"
)
eest_commands = "\n".join(
f"{i+1}. <code>{cmd}</code>" for i, cmd in enumerate(eest_consume_commands)
f"{i + 1}. <code>{cmd}</code>" for i, cmd in enumerate(eest_consume_commands)
)
description += (
"\n\nCommands to reproduce within EEST using a hive dev back-end:" f"\n{eest_commands}"
f"\n\nCommands to reproduce within EEST using a hive dev back-end:\n{eest_commands}"
)
description = description.replace("\n", "<br/>")
return description
Expand Down Expand Up @@ -124,28 +123,37 @@ def client_genesis(blockchain_fixture: BlockchainFixtureCommon) -> dict:


@pytest.fixture(scope="function")
def environment(blockchain_fixture: BlockchainFixtureCommon) -> dict:
"""
Define the environment that hive will start the client with using the fork
rules specific for the simulator.
"""
def check_live_port(test_suite_name: str) -> Literal[8545, 8551]:
"""Port used by hive to check for liveness of the client."""
if test_suite_name == "eest/consume-rlp":
return 8545
elif test_suite_name == "eest/consume-engine":
return 8551
raise ValueError(
f"Unexpected test suite name '{test_suite_name}' while setting HIVE_CHECK_LIVE_PORT."
)


@pytest.fixture(scope="function")
def environment(
blockchain_fixture: BlockchainFixtureCommon, check_live_port: Literal[8545, 8551]
) -> dict:
"""Define the environment that hive will start the client with."""
assert (
blockchain_fixture.fork in ruleset
), f"fork '{blockchain_fixture.fork}' missing in hive ruleset"
return {
"HIVE_CHAIN_ID": "1",
"HIVE_FORK_DAO_VOTE": "1",
"HIVE_NODETYPE": "full",
"HIVE_CHECK_LIVE_PORT": str(check_live_port),
**{k: f"{v:d}" for k, v in ruleset[blockchain_fixture.fork].items()},
}


@pytest.fixture(scope="function")
def buffered_genesis(client_genesis: dict) -> io.BufferedReader:
"""
Create a buffered reader for the genesis block header of the current test
fixture.
"""
"""Create a buffered reader for the genesis block header of the current test fixture."""
genesis_json = json.dumps(client_genesis)
genesis_bytes = genesis_json.encode("utf-8")
return io.BufferedReader(cast(io.RawIOBase, io.BytesIO(genesis_bytes)))
Expand Down

0 comments on commit 2600598

Please sign in to comment.