-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fill): add a config file for the eels resolver to pin versions (#…
…872) * fix(fill): add a config file for the eels resolver to pin versions This config is always used by fill and the framework tests. If the EELS_RESOLUTIONS_FILE is already set, this value is taken instead. This is done via environment variables (no command-line flag added) to be consistent with the resolver behavior. * feat(pytest): copy eels resolutions file to the fixture .meta dir * docs: update changelog * tests(fw): fix filler tests due to introduction of eels_resolution.json * Update src/pytest_plugins/eels_resolver.py --------- Co-authored-by: Mario Vega <[email protected]>
- Loading branch information
1 parent
96efd73
commit 7371ace
Showing
7 changed files
with
155 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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,42 @@ | ||
{ | ||
"EELSMaster": { | ||
"git_url": "https://github.com/ethereum/execution-specs.git", | ||
"branch": "master", | ||
"commit": "9b95554a88d2a8485f8180254d0f6a493a593fda" | ||
}, | ||
"Frontier": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Homestead": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Byzantium": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Constantinople": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Istanbul": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Berlin": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"London": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Paris": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Shanghai": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Cancun": { | ||
"same_as": "EELSMaster" | ||
}, | ||
"Prague": { | ||
"git_url": "https://github.com/ethereum/execution-specs.git", | ||
"branch": "prague", | ||
"commit": "2875a733d6b1e9e751e437c7894d3ebe6ff58ecc" | ||
} | ||
} |
This file contains 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 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 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,93 @@ | ||
""" | ||
Pytest plugin to help working with the `ethereum-spec-evm-resolver`. | ||
This plugin sets the `EELS_RESOLUTIONS_FILE` environment variable to the path | ||
of the `eels_resolutions.json` file in the pytest root directory. If the | ||
environment variable is already set, the plugin will not override it. | ||
""" | ||
|
||
import os | ||
import shutil | ||
from pathlib import Path | ||
|
||
import pytest | ||
from pytest_metadata.plugin import metadata_key # type: ignore | ||
|
||
|
||
def pytest_configure(config: pytest.Config) -> None: | ||
""" | ||
Set the EELS_RESOLUTIONS_FILE environment variable. | ||
Args: | ||
config (pytest.Config): The pytest configuration object. | ||
""" | ||
evm_bin = config.getoption("evm_bin", default=None) | ||
if evm_bin and "resolver" not in str(evm_bin): | ||
# evm_bin is not set for the framework tests: always set the env var. | ||
return | ||
|
||
env_var_name = "EELS_RESOLUTIONS_FILE" | ||
eels_resolutions_file = os.getenv(env_var_name) | ||
|
||
if os.getenv("EELS_RESOLUTIONS"): | ||
# If the user sets this variable, assume they know what they're doing. | ||
return | ||
|
||
if eels_resolutions_file: | ||
file_path = Path(eels_resolutions_file) | ||
if not file_path.is_absolute(): | ||
raise ValueError(f"The path provided in {env_var_name} must be an absolute path.") | ||
if not file_path.exists(): | ||
raise FileNotFoundError( | ||
f"The file {file_path} does not exist. " | ||
f"Ensure the {env_var_name} points to an existing file." | ||
) | ||
else: | ||
root_dir = config.rootpath | ||
default_file_path = root_dir / "eels_resolutions.json" | ||
os.environ[env_var_name] = str(default_file_path) | ||
eels_resolutions_file = str(default_file_path) | ||
|
||
if "Tools" not in config.stash[metadata_key]: | ||
config.stash[metadata_key]["Tools"] = {} | ||
config.stash[metadata_key]["Tools"]["EELS Resolutions"] = str(eels_resolutions_file) | ||
|
||
config._eels_resolutions_file = eels_resolutions_file # type: ignore | ||
|
||
|
||
def pytest_report_header(config: pytest.Config, startdir: Path) -> str: | ||
""" | ||
Report the EELS_RESOLUTIONS_FILE path to the pytest report header. | ||
Args: | ||
config (pytest.Config): The pytest configuration object. | ||
startdir (Path): The starting directory for the test run. | ||
Returns: | ||
str: A string to add to the pytest report header. | ||
""" | ||
eels_resolutions_file = getattr(config, "_eels_resolutions_file", None) | ||
if eels_resolutions_file: | ||
return f"EELS resolutions file: {eels_resolutions_file}" | ||
return "" | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def output_metadata_dir_with_teardown(request): | ||
""" | ||
A session-scoped fixture that attempts to retrieve the filler's | ||
"output_metadata_dir" fixture value and copies the EELS resolutions | ||
file there, if `_eels_resolutions_file` is set on the config object. | ||
""" | ||
yield | ||
try: | ||
output_metadata_dir = request.getfixturevalue("output_metadata_dir") | ||
except pytest.FixtureLookupError: | ||
output_metadata_dir = None | ||
|
||
eels_resolutions_file = getattr(request.config, "_eels_resolutions_file", None) | ||
if output_metadata_dir and eels_resolutions_file: | ||
shutil.copy( | ||
Path(eels_resolutions_file), | ||
Path(output_metadata_dir) / Path(eels_resolutions_file).name, | ||
) |
This file contains 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 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