From f39cd5442b8ddf68dea6ba4cb20ae795c0397a11 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 9 Apr 2024 17:04:53 +0000 Subject: [PATCH] fix(fw): review comment --- src/ethereum_test_tools/code/__init__.py | 3 ++- src/ethereum_test_tools/code/yul.py | 5 ++--- src/ethereum_test_tools/tests/test_code.py | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ethereum_test_tools/code/__init__.py b/src/ethereum_test_tools/code/__init__.py index 86add81a2f..d3abd2ab30 100644 --- a/src/ethereum_test_tools/code/__init__.py +++ b/src/ethereum_test_tools/code/__init__.py @@ -3,7 +3,7 @@ """ from .code import Code from .generators import CalldataCase, Case, CodeGasMeasure, Conditional, Initcode, Switch -from .yul import Yul, YulCompiler +from .yul import Solc, Yul, YulCompiler __all__ = ( "Case", @@ -12,6 +12,7 @@ "CodeGasMeasure", "Conditional", "Initcode", + "Solc", "Switch", "Yul", "YulCompiler", diff --git a/src/ethereum_test_tools/code/yul.py b/src/ethereum_test_tools/code/yul.py index 2652db2183..e3effed504 100644 --- a/src/ethereum_test_tools/code/yul.py +++ b/src/ethereum_test_tools/code/yul.py @@ -12,7 +12,7 @@ from semver import Version -from ethereum_test_forks import Fork, get_closest_fork_with_solc_support +from ethereum_test_forks import Fork from ..common.conversions import to_bytes from .code import Code @@ -80,8 +80,7 @@ def __init__( ): super().__init__(binary) self.source = source - if fork and (fork := get_closest_fork_with_solc_support(fork, self.version)): - self.evm_version = fork.solc_name() + self.evm_version = fork.solc_name() if fork else None @cached_property def compiled(self) -> bytes: diff --git a/src/ethereum_test_tools/tests/test_code.py b/src/ethereum_test_tools/tests/test_code.py index c14b318591..4d8e509cfb 100644 --- a/src/ethereum_test_tools/tests/test_code.py +++ b/src/ethereum_test_tools/tests/test_code.py @@ -8,10 +8,17 @@ import pytest from semver import Version -from ethereum_test_forks import Cancun, Fork, Homestead, Shanghai, get_deployed_forks +from ethereum_test_forks import ( + Cancun, + Fork, + Homestead, + Shanghai, + get_closest_fork_with_solc_support, + get_deployed_forks, +) from evm_transition_tool import FixtureFormats, GethTransitionTool -from ..code import CalldataCase, Case, Code, Conditional, Initcode, Switch, Yul +from ..code import CalldataCase, Case, Code, Conditional, Initcode, Solc, Switch, Yul from ..common import Account, Environment, Hash, TestAddress, Transaction from ..spec import StateTest from ..vm.opcode import Opcodes as Op @@ -66,7 +73,9 @@ def yul_code(request: pytest.FixtureRequest, fork: Fork, padding_before: str, pa else: compiled_yul_code = Code("") for yul_code in yul_code_snippets: - compiled_yul_code += Yul(yul_code, fork=fork) + compiled_yul_code += Yul( + yul_code, fork=get_closest_fork_with_solc_support(fork, Solc().version) + ) if padding_after is not None: compiled_yul_code += Code(padding_after) return compiled_yul_code