Skip to content

Commit

Permalink
fix: fix imports and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Apr 17, 2024
1 parent 73786ec commit f50568e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- name: Run Tests
run: |
pytest tests/test_compiler.py -m "not fuzzing" -n 0 -s \
pytest tests/ -k "not test_coverage" -m "not fuzzing" -n 0 -s \
--cov=ape_vyper \
--cov-branch \
--cov-report term \
Expand Down
23 changes: 21 additions & 2 deletions ape_vyper/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@
_NON_PAYABLE_STR = f"dev: {RuntimeErrorType.NONPAYABLE_CHECK.value}"
Optimization = Union[str, bool]

EVM_VERSION_DEFAULT = {
"0.2.15": "berlin",
"0.2.16": "berlin",
"0.3.0": "berlin",
"0.3.1": "berlin",
"0.3.2": "berlin",
"0.3.3": "berlin",
"0.3.4": "berlin",
"0.3.6": "berlin",
"0.3.7": "paris",
"0.3.8": "shanghai",
"0.3.9": "shanghai",
"0.3.10": "shanghai",
"0.4.0rc2": "shanghai",
}


class FileType(str, Enum):
SOURCE = ".vy"
Expand Down Expand Up @@ -529,7 +545,9 @@ def compile(
for source_id, output_items in result["contracts"].items():
content = {
i + 1: ln
for i, ln in enumerate((contracts_path / source_id).read_text().splitlines())
for i, ln in enumerate(
(contracts_path / source_id).read_text().splitlines()
)
}
for name, output in output_items.items():
# De-compress source map to get PC POS map.
Expand Down Expand Up @@ -1105,7 +1123,8 @@ def _get_compiler_arguments(
bin_arg = self._get_vyper_bin(vyper_version)
arguments_map[vyper_version] = {
"base_path": str(base_path),
"evm_version": self.evm_version,
"evm_version": self.evm_version
or EVM_VERSION_DEFAULT.get(vyper_version.base_version),
"vyper_version": str(vyper_version),
"vyper_binary": bin_arg,
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ vyper:
# Allows importing dependencies.
import_remapping:
- "exampledep=ExampleDependency"

geth:
ethereum:
local:
uri: "http://127.0.0.1:5550"
4 changes: 1 addition & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ def project(config):
@pytest.fixture
def geth_provider():
if not ape.networks.active_provider or ape.networks.provider.name != "geth":
with ape.networks.ethereum.local.use_provider(
"geth", provider_settings={"uri": "http://127.0.0.1:5550"}
) as provider:
with ape.networks.ethereum.local.use_provider("geth") as provider:
yield provider
else:
yield ape.networks.provider
Expand Down
13 changes: 10 additions & 3 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def test_get_version_map(project, compiler, all_versions):

# Vyper 0.4.0 assertions.
actual4 = {x.name for x in actual[VERSION_04]}
expected4 = {'zero_four_module.vy', 'IFaceZeroFour.vyi', 'zero_four.vy', 'sub_reverts_040rc2.vy'}
expected4 = {
"zero_four_module.vy",
"IFaceZeroFour.vyi",
"zero_four.vy",
"sub_reverts_040rc2.vy",
}
assert actual4 == expected4


Expand All @@ -180,8 +185,10 @@ def run_test(manifest):

for compiler in (vyper_028, codesize_latest, true_latest):
assert compiler.name == "vyper"
breakpoint()
assert compiler.settings.get("evmVersion") == "istanbul"

assert vyper_028.settings["evmVersion"] == "berlin"
assert codesize_latest.settings["evmVersion"] == "shanghai"
assert true_latest.settings["evmVersion"] == "shanghai"

# There is only one contract with codesize pragma.
assert codesize_latest.contractTypes == ["optimize_codesize"]
Expand Down

0 comments on commit f50568e

Please sign in to comment.