Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def pytest_addoption(parser: pytest.Parser) -> None: # noqa: D103
)

consume_group.addoption(
"--bin",
"--evm-bin",
action="append",
dest="fixture_consumer_bin",
type=Path,
Expand Down Expand Up @@ -110,16 +110,16 @@ def pytest_configure(config: pytest.Config) -> None: # noqa: D103
(
"No fixture consumer binaries provided; using a dummy "
"consumer for collect-only; all possible fixture formats "
"will be collected. Specify fixture consumer(s) via `--bin` "
"to see actual collection results."
"will be collected. Specify fixture consumer(s) via "
"`--evm-bin` to see actual collection results."
),
stacklevel=1,
)
fixture_consumers = [CollectOnlyFixtureConsumer()]
elif not fixture_consumers:
pytest.exit(
"No fixture consumer binaries provided; please specify a binary "
"path via `--bin`."
"path via `--evm-bin`."
)
config.fixture_consumers = fixture_consumers # type: ignore[attr-defined]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,27 @@ def test_consume_simlimit_collectonly(
if expected_filter_pattern.search(line)
]
assert set(collected_test_ids) == set(expected_collected_test_ids)


def test_direct_consume_requires_evm_bin(
pytester: Pytester,
fixtures_dir: Path,
) -> None:
"""Test that direct consume references --evm-bin in its usage error."""
pytester.copy_example(
name="src/execution_testing/cli/pytest_commands/pytest_ini_files/pytest-consume.ini"
)
consume_test_path = (
"src/execution_testing/cli/pytest_commands/plugins/"
"consume/direct/test_via_direct.py"
)
result = pytester.runpytest_subprocess(
"-c",
"pytest-consume.ini",
"--input",
str(fixtures_dir),
consume_test_path,
)
assert result.ret != pytest.ExitCode.OK
output = "\n".join(result.stdout.lines + result.stderr.lines)
assert "path via `--evm-bin`." in output
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ def pytest_addoption(parser: pytest.Parser) -> None:
default=None,
help=(
"Path to an evm executable (or name of an executable in the "
"PATH) that provides `t8n`. Default: `ethereum-spec-evm-resolver`."
"PATH) that provides `t8n`. Default: use the configured default "
"transition tool."
),
)
evm_group.addoption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import sysconfig
from os.path import realpath
from pathlib import Path
from shutil import which
from typing import Dict, List, Type
from typing import Dict, List

import pytest
from pydantic import TypeAdapter
Expand All @@ -21,7 +20,6 @@

CURRENT_FOLDER = Path(realpath(__file__)).parent
FIXTURES_ROOT = CURRENT_FOLDER / "fixtures"
DEFAULT_EVM_T8N_BINARY_NAME = "ethereum-spec-evm-resolver"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Def worth cleaning up here, but I think we could completely remove this global and the test that uses it. The test is marked as skip, so essentially deadcode atm. The other option is to parametrize the test with other detected t8n tools? But I consider that overkill as we're not missing this test right now and it's implicitly system-tested via the benchchmark tests which use evmone-t8n/geth.



@pytest.fixture(autouse=True)
Expand All @@ -35,8 +33,8 @@ def monkeypatch_path_for_entry_points(
This would typically be in the venv in which pytest is running these tests
and fill, which, with uv, is `./.venv/bin`.

This is required in order for fill to locate the ethereum-spec-evm-resolver
"binary" (entrypoint) when being executed using pytester.
This is required so pytester-based invocations can locate the
`ethereum-spec-evm t8n` entrypoint while running in tests.
"""
bin_dir = sysconfig.get_path("scripts")
monkeypatch.setenv("PATH", f"{bin_dir}:{os.environ['PATH']}")
Expand Down Expand Up @@ -96,39 +94,6 @@ def test_calc_state_root(
assert Alloc(alloc).state_root().startswith(expected_hash)


@pytest.mark.parametrize("evm_tool", [ExecutionSpecsTransitionTool])
@pytest.mark.parametrize(
"binary_arg", ["no_binary_arg", "path_type", "str_type"]
)
@pytest.mark.skip(
reason="ExecutionSpecsTransitionTool through binary path is not supported"
)
def test_evm_tool_binary_arg(
evm_tool: Type[ExecutionSpecsTransitionTool], binary_arg: str
) -> None:
"""Test the `evm_tool` binary argument."""
if binary_arg == "no_binary_arg":
evm_tool().version()
return
elif binary_arg == "path_type":
evm_bin = which(DEFAULT_EVM_T8N_BINARY_NAME)
if not evm_bin:
# typing: Path can not take None; but if None, we may
# as well fail explicitly.
raise Exception(
f"Failed to find `{DEFAULT_EVM_T8N_BINARY_NAME}` "
"in the PATH via which"
)
evm_tool(binary=Path(evm_bin)).version()
return
elif binary_arg == "str_type":
evm_bin_str = which(DEFAULT_EVM_T8N_BINARY_NAME)
if evm_bin_str:
evm_tool(binary=Path(evm_bin_str)).version()
return
raise Exception("unknown test parameter")


transaction_type_adapter = TypeAdapter(List[Transaction])


Expand Down
Loading