Skip to content

Commit c31efcc

Browse files
committed
removed solc dependency (#1759)
1 parent bb2992c commit c31efcc

File tree

19 files changed

+434
-514
lines changed

19 files changed

+434
-514
lines changed

docs/writing_tests/tutorials/state_transition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The most effective method of learning how to write tests is to study a couple of
1818

1919
### Yul Test
2020

21-
You can find the source code for the Yul test in [tests/homestead/yul/test_yul_example.py](../../tests/homestead/yul/test_yul_example/index.md).
21+
You can find the source code for the Yul test in `tests/homestead/yul/test_yul_example.py`.
2222
It is the spec test equivalent of this [static test](https://github.com/ethereum/tests/blob/develop/src/GeneralStateTestsFiller/stExample/yulExampleFiller.yml).
2323

2424
Lets examine each section.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ dependencies = [
3838
"semver>=3.0.1,<4",
3939
"pydantic>=2.10.0,<3",
4040
"rich>=13.7.0,<14",
41-
"solc-select>=1.0.4,<2",
4241
"filelock>=3.15.1,<4",
4342
"ethereum-types>=0.2.1,<0.3",
4443
"pyyaml>=6.0.2,<7",
@@ -50,6 +49,7 @@ dependencies = [
5049
"pytest-regex>=0.2.0,<0.3",
5150
"eth-abi>=5.2.0",
5251
"joblib>=1.4.2",
52+
"ckzg>=2.1.1,<3",
5353
]
5454

5555
[project.urls]

pytest-check-eip-versions.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ addopts =
1111
-p pytest_plugins.spec_version_checker.spec_version_checker
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.filler.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.filler.filler
1615
-p pytest_plugins.shared.execute_fill
1716
-p pytest_plugins.forks.forks

pytest-execute-hive.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ addopts =
1111
-p pytest_plugins.concurrency
1212
-p pytest_plugins.execute.sender
1313
-p pytest_plugins.execute.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.execute.rpc.hive
1615
-p pytest_plugins.execute.execute
1716
-p pytest_plugins.shared.execute_fill

pytest-execute.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ addopts =
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.execute.sender
1414
-p pytest_plugins.execute.pre_alloc
15-
-p pytest_plugins.solc.solc
1615
-p pytest_plugins.execute.execute
1716
-p pytest_plugins.shared.execute_fill
1817
-p pytest_plugins.execute.rpc.remote_seed_sender

pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ markers =
1111
addopts =
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.filler.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.filler.filler
16-
-p pytest_plugins.filler.static_filler
1715
-p pytest_plugins.filler.ported_tests
1816
-p pytest_plugins.shared.execute_fill
1917
-p pytest_plugins.forks.forks

src/ethereum_test_tools/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
Initcode,
8383
Switch,
8484
While,
85-
Yul,
86-
YulCompiler,
8785
)
8886
from .utility.generators import (
8987
DeploymentTestType,
@@ -157,8 +155,6 @@
157155
"While",
158156
"Withdrawal",
159157
"WithdrawalRequest",
160-
"Yul",
161-
"YulCompiler",
162158
"add_kzg_version",
163159
"call_return_code",
164160
"ceiling_division",

src/pytest_plugins/filler/filler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,11 @@ def fixture_collector(
764764
Return configured fixture collector instance used for all tests
765765
in one test module.
766766
"""
767+
# Dynamically load the 'static_filler' and 'solc' plugins if needed
768+
if request.config.getoption("fill_static_tests_enabled"):
769+
request.config.pluginmanager.import_plugin("pytest_plugins.filler.static_filler")
770+
request.config.pluginmanager.import_plugin("pytest_plugins.solc.solc")
771+
767772
fixture_collector = FixtureCollector(
768773
output_dir=fixture_output.directory,
769774
flat_output=fixture_output.flat_output,

src/pytest_plugins/filler/static_filler.py

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
from _pytest.python import Module
1818

1919
from ethereum_test_fixtures import BaseFixture, LabeledFixtureFormat
20-
from ethereum_test_forks import Fork
20+
from ethereum_test_forks import (
21+
Fork,
22+
get_closest_fork_with_solc_support,
23+
get_forks_with_solc_support,
24+
)
2125
from ethereum_test_specs import BaseStaticTest, BaseTest
26+
from ethereum_test_tools.code.yul import Yul
2227

2328
from ..forks.forks import ValidityMarker, get_intersection_set
2429
from ..shared.helpers import labeled_format_parameter_set
@@ -109,18 +114,6 @@ def get_all_combinations_from_parametrize_marks(
109114
return all_argument_names, all_value_combinations
110115

111116

112-
def pytest_addoption(parser: pytest.Parser):
113-
"""Add command-line options to pytest."""
114-
static_filler_group = parser.getgroup("static", "Arguments defining static filler behavior")
115-
static_filler_group.addoption(
116-
"--fill-static-tests",
117-
action="store_true",
118-
dest="fill_static_tests_enabled",
119-
default=None,
120-
help=("Enable reading and filling from static test files."),
121-
)
122-
123-
124117
def pytest_collect_file(file_path: Path, parent) -> pytest.Collector | None:
125118
"""Pytest hook that collects test cases from static files and fills them into test fixtures."""
126119
fill_static_tests_enabled = parent.config.getoption("fill_static_tests_enabled")
@@ -334,3 +327,46 @@ def runtest(self):
334327
def reportinfo(self):
335328
"""Provide information for test reporting."""
336329
return self.fspath, 0, f"Static file test: {self.name}"
330+
331+
332+
@pytest.fixture
333+
def yul(fork: Fork, request: pytest.FixtureRequest):
334+
"""
335+
Fixture that allows contract code to be defined with Yul code.
336+
337+
This fixture defines a class that wraps the ::ethereum_test_tools.Yul
338+
class so that upon instantiation within the test case, it provides the
339+
test case's current fork parameter. The forks is then available for use
340+
in solc's arguments for the Yul code compilation.
341+
342+
Test cases can override the default value by specifying a fixed version
343+
with the @pytest.mark.compile_yul_with(FORK) marker.
344+
"""
345+
solc_target_fork: Fork | None
346+
marker = request.node.get_closest_marker("compile_yul_with")
347+
assert hasattr(request.config, "solc_version"), "solc_version not set in pytest config."
348+
if marker:
349+
if not marker.args[0]:
350+
pytest.fail(
351+
f"{request.node.name}: Expected one argument in 'compile_yul_with' marker."
352+
)
353+
for fork in request.config.all_forks: # type: ignore
354+
if fork.name() == marker.args[0]:
355+
solc_target_fork = fork
356+
break
357+
else:
358+
pytest.fail(f"{request.node.name}: Fork {marker.args[0]} not found in forks list.")
359+
assert solc_target_fork in get_forks_with_solc_support(request.config.solc_version)
360+
else:
361+
solc_target_fork = get_closest_fork_with_solc_support(fork, request.config.solc_version)
362+
assert solc_target_fork is not None, "No fork supports provided solc version."
363+
if solc_target_fork != fork and request.config.getoption("verbose") >= 1:
364+
warnings.warn(
365+
f"Compiling Yul for {solc_target_fork.name()}, not {fork.name()}.", stacklevel=2
366+
)
367+
368+
class YulWrapper(Yul):
369+
def __new__(cls, *args, **kwargs):
370+
return super(YulWrapper, cls).__new__(cls, *args, **kwargs, fork=solc_target_fork)
371+
372+
return YulWrapper

src/pytest_plugins/help/tests/test_help.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
FILL_TEST_ARGS = (
66
"--evm-bin",
77
"--traces",
8-
"--solc-bin",
98
"--filler-path",
109
"--output",
1110
"--forks",

0 commit comments

Comments
 (0)