Skip to content

Commit aa628e9

Browse files
committed
chore: Don't convert state tests to sync tests
- Don't convert state tests to sync tests - Simplify skipping sync tests if ``verify_sync`` is not ``True``. If the tests uses ``verify_sync`` at all, add the marker to it. If the marker is later checked to be ``False`` (invalid payloads), skip the test.
1 parent 3664399 commit aa628e9

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

src/ethereum_test_specs/blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def generate(
835835
"""Generate the BlockchainTest fixture."""
836836
# Skip sync fixture generation if verify_sync is False
837837
if fixture_format == BlockchainEngineSyncFixture and not self.verify_sync:
838-
raise pytest.skip("Skipping sync fixture for test without verify_sync=True")
838+
raise pytest.skip(f"Skipping sync fixture, verify_sync={self.verify_sync}")
839839

840840
t8n.reset_traces()
841841
if fixture_format in [

src/ethereum_test_specs/state.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class StateTest(BaseTest):
6161
f"A {fixture_format.format_name} generated from a state_test",
6262
)
6363
for fixture_format in BlockchainTest.supported_fixture_formats
64+
# Exclude sync fixtures from state tests - they don't make sense for state tests
65+
if not (
66+
(hasattr(fixture_format, "__name__") and "Sync" in fixture_format.__name__)
67+
or (hasattr(fixture_format, "format") and "Sync" in fixture_format.format.__name__)
68+
)
6469
]
6570
supported_execute_formats: ClassVar[Sequence[LabeledExecuteFormat]] = [
6671
LabeledExecuteFormat(

src/pytest_plugins/filler/filler.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import configparser
1010
import datetime
11+
import inspect
1112
import os
1213
import warnings
1314
from enum import Enum
@@ -1121,11 +1122,9 @@ def pytest_collection_modifyitems(
11211122
parametrization occurs in the forks plugin.
11221123
11231124
Also dynamically adds custom markers to tests based on their parameters (e.g.,
1124-
`blockchain_test_sync_only` for tests that have `verify_sync=True` in their
1125+
`blockchain_test_sync_only` for tests that have `verify_sync` in their
11251126
`blockchain_test` parameters).
11261127
"""
1127-
import inspect
1128-
11291128
items_for_removal = []
11301129
for i, item in enumerate(items):
11311130
params: Dict[str, Any] | None = None
@@ -1146,27 +1145,14 @@ def pytest_collection_modifyitems(
11461145
items_for_removal.append(i)
11471146
continue
11481147

1149-
# Check if test has ``verify_sync=True`` and add marker if it does
1150-
# This needs to happen before we check ``discard_fixture_format_by_marks``
1151-
if hasattr(item, "function"):
1152-
try:
1153-
test_func = item.function
1154-
source = inspect.getsource(test_func)
1155-
if "verify_sync=True" in source:
1156-
# Add the marker so pytest can filter it with `-m`
1157-
item.add_marker(pytest.mark.blockchain_test_sync_only)
1158-
except Exception:
1159-
pass # If we can't inspect, just continue
1148+
# Add ``blockchain_test_sync_only`` marker to blockchain fixture if it uses
1149+
# ``verify_sync``
1150+
if fixture_format == BlockchainEngineSyncFixture and isinstance(item, pytest.Function):
1151+
source = inspect.getsource(item.function)
1152+
if "verify_sync" in source:
1153+
item.add_marker(pytest.mark.blockchain_test_sync_only)
11601154

11611155
markers = list(item.iter_markers())
1162-
# Check for ``-m blockchain_test_sync_only`` and only fill sync tests
1163-
if (
1164-
config.getoption("-m") == "blockchain_test_sync_only"
1165-
and "blockchain_test_sync_only" in [m.name for m in markers]
1166-
and fixture_format != BlockchainEngineSyncFixture
1167-
):
1168-
items_for_removal.append(i)
1169-
continue
11701156
if spec_type.discard_fixture_format_by_marks(fixture_format, fork, markers):
11711157
items_for_removal.append(i)
11721158
continue

0 commit comments

Comments
 (0)