-
Notifications
You must be signed in to change notification settings - Fork 460
feat(test-cli): Add support for testing block building via simulator #2679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fselmo
merged 6 commits into
ethereum:forks/amsterdam
from
fselmo:feat/block-building-tests
May 13, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aa4fd31
feat(test-cli): Add support for testing block building via simulator
fselmo 679ff43
chore: pretty diff BALs on errors
fselmo 795a4f9
refactor(test): cleanup based on comments on PR #2679
fselmo 7a2db76
chore: cleanup from comments on PR #2679
fselmo ff28369
chore: initial docs for build-block
fselmo a884759
chore: e2e run for block-building tests; tighten up docs
fselmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/testing/src/execution_testing/cli/pytest_commands/build_block.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| """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("consume"), | ||
| HiveEnvironmentProcessor(command_name="build_block"), | ||
| ConsumeCommandProcessor(is_hive=True), | ||
| ], | ||
| command_logic_test_paths=command_logic_test_paths, | ||
| ) | ||
|
|
||
|
|
||
| @click.command( | ||
| name="build-block", | ||
|
danceratopz marked this conversation as resolved.
|
||
| context_settings={"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)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.../execution_testing/cli/pytest_commands/plugins/consume/simulators/build_block/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Pytest configuration for the build-block simulator.""" |
66 changes: 66 additions & 0 deletions
66
.../execution_testing/cli/pytest_commands/plugins/consume/simulators/build_block/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did wonder if there was a better test set to use here, something with multiple blocks?
test_clz_stack_underflowis a state test, therefore single block.