Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions packages/testing/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ checkfixtures = "execution_testing.cli.check_fixtures:check_fixtures"
check_eip_versions = "execution_testing.cli.pytest_commands.check_eip_versions:check_eip_versions"
consume = "execution_testing.cli.pytest_commands.consume:consume"
protec = "execution_testing.cli.pytest_commands.consume:consume"
build-block = "execution_testing.cli.pytest_commands.build_block:build_block"
checklist = "execution_testing.cli.pytest_commands.checklist:checklist"
generate_checklist_stubs = "execution_testing.cli.generate_checklist_stubs:generate_checklist_stubs"
genindex = "execution_testing.cli.gen_index:generate_fixtures_index_cli"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""CLI entry point for the `build-block` pytest-based command."""

from pathlib import Path
from typing import Any, List

import click

from .base import PytestCommand, common_pytest_options
from .processors import (
ConsumeCommandProcessor,
HelpFlagsProcessor,
HiveEnvironmentProcessor,
)


def create_build_block_command() -> PytestCommand:
"""Initialize the build-block command with paths and processors."""
base_path = Path("cli/pytest_commands/plugins/consume")
command_logic_test_paths = [
base_path / "simulators" / "simulator_logic" / "test_via_build.py"
]
return PytestCommand(
config_file="pytest-consume.ini",
argument_processors=[
HelpFlagsProcessor("build_block"),
Comment thread
fselmo marked this conversation as resolved.
Outdated
HiveEnvironmentProcessor(command_name="build_block"),
ConsumeCommandProcessor(is_hive=True),
],
command_logic_test_paths=command_logic_test_paths,
)


@click.command(
name="build-block",
Comment thread
danceratopz marked this conversation as resolved.
context_settings={
"help_option_names": ["-h", "--help"],
Comment thread
fselmo marked this conversation as resolved.
Outdated
"ignore_unknown_options": True,
},
)
@common_pytest_options
def build_block(pytest_args: List[str], **kwargs: Any) -> None:
"""Test block building via testing_buildBlockV1."""
del kwargs

cmd = create_build_block_command()
cmd.execute(list(pytest_args))
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def check_live_port(test_suite_name: str) -> Literal[8545, 8551]:
"eels/consume-engine",
"eels/consume-enginex",
"eels/consume-sync",
"eels/build-block",
}:
return 8551
raise ValueError(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pytest configuration for the build-block simulator."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
Pytest fixtures for the `build-block` simulator.

Configures the hive back-end & EL clients for block building correctness
testing via the ``testing_buildBlockV1`` endpoint.
"""

import io
from typing import Mapping

import pytest
from hive.client import Client

from execution_testing.fixtures import BlockchainEngineFixture
from execution_testing.fixtures.blockchain import FixtureHeader
from execution_testing.rpc import TestingRPC

pytest_plugins = (
"execution_testing.cli.pytest_commands.plugins.pytest_hive.pytest_hive",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.base",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.single_test_client",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.test_case_description",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.timing_data",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.exceptions",
"execution_testing.cli.pytest_commands.plugins.consume.simulators.engine_api",
)


def pytest_configure(config: pytest.Config) -> None:
"""Set the supported fixture formats for the build-block simulator."""
config.supported_fixture_formats = [BlockchainEngineFixture] # type: ignore[attr-defined]


@pytest.fixture(scope="module")
def test_suite_name() -> str:
"""The name of the hive test suite used in this simulator."""
return "eels/build-block"


@pytest.fixture(scope="module")
def test_suite_description() -> str:
"""The description of the hive test suite used in this simulator."""
return (
"Test block building correctness via the "
"testing_buildBlockV1 endpoint."
)


@pytest.fixture(scope="function")
def client_files(
buffered_genesis: io.BufferedReader,
) -> Mapping[str, io.BufferedReader]:
"""Define the files that hive will start the client with."""
return {"/genesis.json": buffered_genesis}


@pytest.fixture(scope="function")
def genesis_header(fixture: BlockchainEngineFixture) -> FixtureHeader:
"""Provide the genesis header from the fixture."""
return fixture.genesis


@pytest.fixture(scope="function")
def testing_rpc(client: Client) -> TestingRPC:
"""Initialize Testing RPC client for the execution client under test."""
return TestingRPC(f"http://{client.ip}:8545")
Loading
Loading