simplify using reviewer suggestions

pull/1808/head
alpharush 2 years ago
parent 0d3115fda0
commit 07fcb5c149
  1. 9
      Makefile
  2. 27
      tests/conftest.py
  3. 9
      tests/e2e/compilation/test_resolution.py
  4. 4
      tests/tools/read-storage/test_read_storage.py
  5. 5
      tests/unit/core/test_arithmetic.py
  6. 18
      tests/unit/core/test_code_comments.py
  7. 20
      tests/unit/core/test_constant_folding.py
  8. 21
      tests/unit/core/test_contract_declaration.py
  9. 17
      tests/unit/core/test_function_declaration.py
  10. 12
      tests/unit/core/test_source_mapping.py
  11. 5
      tests/unit/core/test_storage_layout.py
  12. 43
      tests/unit/core/test_using_for.py
  13. 5
      tests/unit/slithir/test_operation_reads.py
  14. 5
      tests/unit/slithir/test_ssa_generation.py
  15. 4
      tests/unit/slithir/test_ternary_expressions.py
  16. 5
      tests/unit/utils/test_code_generation.py
  17. 5
      tests/unit/utils/test_functions_ids.py
  18. 5
      tests/unit/utils/test_type_helpers.py

@ -1,6 +1,7 @@
SHELL := /bin/bash
PY_MODULE := slither
TEST_MODULE := tests
ALL_PY_SRCS := $(shell find $(PY_MODULE) -name '*.py') \
$(shell find test -name '*.py')
@ -33,7 +34,7 @@ ifneq ($(TESTS),)
COV_ARGS :=
else
TEST_ARGS := -n auto
COV_ARGS := --cov-append # --fail-under 100
COV_ARGS := # --fail-under 100
endif
.PHONY: all
@ -56,15 +57,15 @@ $(VENV)/pyvenv.cfg: pyproject.toml
.PHONY: lint
lint: $(VENV)/pyvenv.cfg
. $(VENV_BIN)/activate && \
black --check $(ALL_PY_SRCS) && \
pylint $(ALL_PY_SRCS)
black --check . && \
pylint $(PY_MODULE) $(TEST_MODULE)
# ruff $(ALL_PY_SRCS) && \
# mypy $(PY_MODULE) &&
.PHONY: reformat
reformat:
. $(VENV_BIN)/activate && \
black $(PY_MODULE)
black .
.PHONY: test tests
test tests: $(VENV)/pyvenv.cfg

@ -2,26 +2,15 @@ import pytest
from filelock import FileLock
from solc_select import solc_select
@pytest.fixture(scope="session")
def solc_versions_installed():
"""List of solc versions available in the test environment."""
return []
@pytest.fixture(scope="session", autouse=True)
def register_solc_versions_installed(solc_versions_installed):
solc_versions_installed.extend(solc_select.installed_versions())
@pytest.fixture(scope="session")
def use_solc_version(request, solc_versions_installed):
def _use_solc_version(version):
print(version)
if version not in solc_versions_installed:
def solc_binary_path():
def inner(version):
lock = FileLock(f"{version}.lock", timeout=60)
with lock:
if not solc_select.artifact_path(version).exists():
print("Installing solc version", version)
solc_select.install_artifacts([version])
artifact_path = solc_select.artifact_path(version)
lock = FileLock(artifact_path)
try:
yield artifact_path
finally:
lock.release()
return _use_solc_version
return solc_select.artifact_path(version)
return inner

@ -3,7 +3,6 @@ import pytest
from crytic_compile import CryticCompile
from crytic_compile.platform.solc_standard_json import SolcStandardJson
from solc_select import solc_select
from slither import Slither
@ -24,8 +23,8 @@ def test_node_modules() -> None:
_run_all_detectors(slither)
def test_contract_name_collision(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.0"))
def test_contract_name_collision(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
standard_json = SolcStandardJson()
standard_json.add_source_file(
Path(TEST_DATA_DIR, "test_contract_name_collisions", "a.sol").as_posix()
@ -40,7 +39,7 @@ def test_contract_name_collision(use_solc_version) -> None:
_run_all_detectors(slither)
def test_cycle(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.0"))
def test_cycle(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
slither = Slither(Path(TEST_DATA_DIR, "test_cyclic_import", "a.sol").as_posix(), solc=solc_path)
_run_all_detectors(slither)

@ -90,8 +90,8 @@ def deploy_contract(w3, ganache, contract_bin, contract_abi) -> Contract:
# pylint: disable=too-many-locals
@pytest.mark.usefixtures("web3", "ganache")
def test_read_storage(web3, ganache, use_solc_version) -> None:
solc_path = next(use_solc_version(version="0.8.10"))
def test_read_storage(web3, ganache, solc_binary_path) -> None:
solc_path = solc_binary_path(version="0.8.10")
assert web3.is_connected()
bin_path = Path(TEST_DATA_DIR, "StorageLayout.bin").as_posix()

@ -1,5 +1,4 @@
from pathlib import Path
from solc_select import solc_select
from slither import Slither
from slither.utils.arithmetic import unchecked_arithemtic_usage
@ -8,8 +7,8 @@ from slither.utils.arithmetic import unchecked_arithemtic_usage
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" / "arithmetic_usage"
def test_arithmetic_usage(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
def test_arithmetic_usage(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(Path(TEST_DATA_DIR, "test.sol").as_posix(), solc=solc_path)
assert {

@ -8,8 +8,8 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
CUSTOM_COMMENTS_TEST_DATA_DIR = Path(TEST_DATA_DIR, "custom_comments")
def test_upgradeable_comments(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.10"))
def test_upgradeable_comments(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.10")
slither = Slither(Path(CUSTOM_COMMENTS_TEST_DATA_DIR, "upgrade.sol").as_posix(), solc=solc_path)
compilation_unit = slither.compilation_units[0]
proxy = compilation_unit.get_contract_from_name("Proxy")[0]
@ -27,11 +27,13 @@ def test_upgradeable_comments(use_solc_version) -> None:
assert v1.upgradeable_version == "version_1"
def test_contract_comments(use_solc_version) -> None:
def test_contract_comments(solc_binary_path) -> None:
comments = " @title Test Contract\n @dev Test comment"
solc_path = next(use_solc_version("0.8.10"))
slither = Slither(Path(CUSTOM_COMMENTS_TEST_DATA_DIR, "contract_comment.sol").as_posix(), solc=solc_path)
solc_path = solc_binary_path("0.8.10")
slither = Slither(
Path(CUSTOM_COMMENTS_TEST_DATA_DIR, "contract_comment.sol").as_posix(), solc=solc_path
)
compilation_unit = slither.compilation_units[0]
contract = compilation_unit.get_contract_from_name("A")[0]
@ -40,8 +42,10 @@ def test_contract_comments(use_solc_version) -> None:
# Old solc versions have a different parsing of comments
# the initial space (after *) is also not kept on every line
comments = "@title Test Contract\n@dev Test comment"
solc_path = next(use_solc_version("0.5.16"))
slither = Slither(Path(CUSTOM_COMMENTS_TEST_DATA_DIR, "contract_comment.sol").as_posix(), solc=solc_path)
solc_path = solc_binary_path("0.5.16")
slither = Slither(
Path(CUSTOM_COMMENTS_TEST_DATA_DIR, "contract_comment.sol").as_posix(), solc=solc_path
)
compilation_unit = slither.compilation_units[0]
contract = compilation_unit.get_contract_from_name("A")[0]

@ -6,15 +6,17 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
CONSTANT_FOLDING_TEST_ROOT = Path(TEST_DATA_DIR, "constant_folding")
def test_constant_folding_unary(use_solc_version):
solc_path = next(use_solc_version("0.8.0"))
def test_constant_folding_unary(solc_binary_path):
solc_path = solc_binary_path("0.8.0")
file = Path(CONSTANT_FOLDING_TEST_ROOT, "constant_folding_unary.sol").as_posix()
Slither(file, solc=solc_path)
def test_constant_folding_rational(use_solc_version):
solc_path = next(use_solc_version("0.8.0"))
s = Slither(Path(CONSTANT_FOLDING_TEST_ROOT, "constant_folding_rational.sol").as_posix(), solc=solc_path)
def test_constant_folding_rational(solc_binary_path):
solc_path = solc_binary_path("0.8.0")
s = Slither(
Path(CONSTANT_FOLDING_TEST_ROOT, "constant_folding_rational.sol").as_posix(), solc=solc_path
)
contract = s.get_contract_from_name("C")[0]
variable_a = contract.get_state_variable_from_name("a")
@ -52,9 +54,11 @@ def test_constant_folding_rational(use_solc_version):
assert str(ConstantFolding(variable_g.expression, "int64").result()) == "-7"
def test_constant_folding_binary_expressions(use_solc_version):
solc_path = next(use_solc_version("0.8.0"))
sl = Slither(Path(CONSTANT_FOLDING_TEST_ROOT, "constant_folding_binop.sol").as_posix(), solc=solc_path)
def test_constant_folding_binary_expressions(solc_binary_path):
solc_path = solc_binary_path("0.8.0")
sl = Slither(
Path(CONSTANT_FOLDING_TEST_ROOT, "constant_folding_binop.sol").as_posix(), solc=solc_path
)
contract = sl.get_contract_from_name("BinOp")[0]
variable_a = contract.get_state_variable_from_name("a")

@ -1,6 +1,5 @@
from pathlib import Path
from solc_select import solc_select
from slither import Slither
from slither.core.variables.state_variable import StateVariable
@ -9,26 +8,30 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
CONTRACT_DECL_TEST_ROOT = Path(TEST_DATA_DIR, "contract_declaration")
def test_abstract_contract(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.0"))
def test_abstract_contract(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
slither = Slither(Path(CONTRACT_DECL_TEST_ROOT, "abstract.sol").as_posix(), solc=solc_path)
assert not slither.contracts[0].is_fully_implemented
solc_path = next(use_solc_version("0.5.0"))
slither = Slither(Path(CONTRACT_DECL_TEST_ROOT, "implicit_abstract.sol").as_posix(), solc=solc_path)
solc_path = solc_binary_path("0.5.0")
slither = Slither(
Path(CONTRACT_DECL_TEST_ROOT, "implicit_abstract.sol").as_posix(), solc=solc_path
)
assert not slither.contracts[0].is_fully_implemented
slither = Slither(
Path(CONTRACT_DECL_TEST_ROOT, "implicit_abstract.sol").as_posix(),
solc_force_legacy_json=True,
solc=solc_path
solc=solc_path,
)
assert not slither.contracts[0].is_fully_implemented
def test_private_variable(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
slither = Slither(Path(CONTRACT_DECL_TEST_ROOT, "private_variable.sol").as_posix(), solc=solc_path)
def test_private_variable(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(CONTRACT_DECL_TEST_ROOT, "private_variable.sol").as_posix(), solc=solc_path
)
contract_c = slither.get_contract_from_name("C")[0]
f = contract_c.functions[0]
var_read = f.variables_read[0]

@ -5,7 +5,6 @@ tests that `tests/test_function.sol` gets translated into correct
and that these objects behave correctly.
"""
from pathlib import Path
from solc_select import solc_select
from slither import Slither
from slither.core.declarations.function import FunctionType
@ -15,9 +14,9 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
FUNC_DELC_TEST_ROOT = Path(TEST_DATA_DIR, "function_declaration")
def test_functions(use_solc_version):
def test_functions(solc_binary_path):
# pylint: disable=too-many-statements
solc_path = next(use_solc_version("0.6.12"))
solc_path = solc_binary_path("0.6.12")
file = Path(FUNC_DELC_TEST_ROOT, "test_function.sol").as_posix()
slither = Slither(file, solc=solc_path)
functions = slither.get_contract_from_name("TestFunction")[0].available_functions_as_dict()
@ -248,8 +247,8 @@ def test_functions(use_solc_version):
assert f.return_type[0] == ElementaryType("bool")
def test_function_can_send_eth(use_solc_version):
solc_path = next(use_solc_version("0.6.12"))
def test_function_can_send_eth(solc_binary_path):
solc_path = solc_binary_path("0.6.12")
file = Path(FUNC_DELC_TEST_ROOT, "test_function.sol").as_posix()
slither = Slither(file, solc=solc_path)
compilation_unit = slither.compilation_units[0]
@ -273,8 +272,8 @@ def test_function_can_send_eth(use_solc_version):
assert functions["highlevel_call_via_external()"].can_send_eth() is False
def test_reentrant(use_solc_version):
solc_path = next(use_solc_version("0.8.10"))
def test_reentrant(solc_binary_path):
solc_path = solc_binary_path("0.8.10")
file = Path(FUNC_DELC_TEST_ROOT, "test_function_reentrant.sol").as_posix()
slither = Slither(file, solc=solc_path)
compilation_unit = slither.compilation_units[0]
@ -290,8 +289,8 @@ def test_reentrant(use_solc_version):
assert functions["internal_and_reentrant()"].is_reentrant
def test_public_variable(use_solc_version) -> None:
solc_path = next(use_solc_version("0.6.12"))
def test_public_variable(solc_binary_path) -> None:
solc_path = solc_binary_path("0.6.12")
file = Path(FUNC_DELC_TEST_ROOT, "test_function.sol").as_posix()
slither = Slither(file, solc=solc_path)
contracts = slither.get_contract_from_name("TestFunction")

@ -8,8 +8,8 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
SRC_MAPPING_TEST_ROOT = Path(TEST_DATA_DIR, "src_mapping")
def test_source_mapping(use_solc_version):
solc_path = next(use_solc_version("0.6.12"))
def test_source_mapping(solc_binary_path):
solc_path = solc_binary_path("0.6.12")
file = Path(SRC_MAPPING_TEST_ROOT, "inheritance.sol").as_posix()
slither = Slither(file, solc=solc_path)
@ -78,11 +78,11 @@ def _sort_references_lines(refs: list) -> list:
return sorted([ref.lines[0] for ref in refs])
def test_references_user_defined_aliases(use_solc_version):
def test_references_user_defined_aliases(solc_binary_path):
"""
Tests if references are filled correctly for user defined aliases (declared using "type [...] is [...]" statement).
"""
solc_path = next(use_solc_version("0.8.16"))
solc_path = solc_binary_path("0.8.16")
file = Path(SRC_MAPPING_TEST_ROOT, "ReferencesUserDefinedAliases.sol").as_posix()
slither = Slither(file, solc=solc_path)
@ -101,11 +101,11 @@ def test_references_user_defined_aliases(use_solc_version):
assert lines == [13, 16]
def test_references_user_defined_types_when_casting(use_solc_version):
def test_references_user_defined_types_when_casting(solc_binary_path):
"""
Tests if references are filled correctly for user defined types in case of casting.
"""
solc_path = next(use_solc_version("0.8.16"))
solc_path = solc_binary_path("0.8.16")
file = Path(SRC_MAPPING_TEST_ROOT, "ReferencesUserDefinedTypesCasting.sol").as_posix()
slither = Slither(file, solc=solc_path)

@ -1,16 +1,15 @@
import json
from pathlib import Path
from subprocess import PIPE, Popen
from solc_select import solc_select
from slither import Slither
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
STORAGE_TEST_ROOT = Path(TEST_DATA_DIR, "storage_layout")
def test_storage_layout(use_solc_version):
def test_storage_layout(solc_binary_path):
# the storage layout has not yet changed between solidity versions so we will test with one version of the compiler
solc_path = next(use_solc_version("0.8.10"))
solc_path = solc_binary_path("0.8.10")
test_item = Path(STORAGE_TEST_ROOT, "storage_layout-0.8.10.sol").as_posix()
sl = Slither(test_item, disallow_partial=True, solc=solc_path)

@ -1,7 +1,6 @@
from pathlib import Path
from crytic_compile import CryticCompile
from crytic_compile.platform.solc_standard_json import SolcStandardJson
from solc_select import solc_select
from slither import Slither
from slither.slithir.operations import InternalCall, LibraryCall
@ -12,8 +11,8 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
USING_FOR_TEST_DATA_DIR = Path(TEST_DATA_DIR, "using_for")
def test_using_for_global_collision(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
def test_using_for_global_collision(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
standard_json = SolcStandardJson()
for source_file in Path(USING_FOR_TEST_DATA_DIR, "using_for_global_collision").rglob("*.sol"):
standard_json.add_source_file(Path(source_file).as_posix())
@ -22,9 +21,11 @@ def test_using_for_global_collision(use_solc_version) -> None:
_run_all_detectors(sl)
def test_using_for_top_level_same_name(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-3-0.8.0.sol").as_posix(), solc=solc_path)
def test_using_for_top_level_same_name(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(USING_FOR_TEST_DATA_DIR, "using-for-3-0.8.0.sol").as_posix(), solc=solc_path
)
contract_c = slither.get_contract_from_name("C")[0]
libCall = contract_c.get_function_from_full_name("libCall(uint256)")
for ir in libCall.all_slithir_operations():
@ -33,9 +34,11 @@ def test_using_for_top_level_same_name(use_solc_version) -> None:
assert False
def test_using_for_top_level_implicit_conversion(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-4-0.8.0.sol").as_posix(), solc=solc_path)
def test_using_for_top_level_implicit_conversion(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(USING_FOR_TEST_DATA_DIR, "using-for-4-0.8.0.sol").as_posix(), solc=solc_path
)
contract_c = slither.get_contract_from_name("C")[0]
libCall = contract_c.get_function_from_full_name("libCall(uint16)")
for ir in libCall.all_slithir_operations():
@ -44,10 +47,11 @@ def test_using_for_top_level_implicit_conversion(use_solc_version) -> None:
assert False
def test_using_for_alias_top_level(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
def test_using_for_alias_top_level(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-top-level-0.8.0.sol").as_posix(), solc=solc_path
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-top-level-0.8.0.sol").as_posix(),
solc=solc_path,
)
contract_c = slither.get_contract_from_name("C")[0]
libCall = contract_c.get_function_from_full_name("libCall(uint256)")
@ -64,10 +68,11 @@ def test_using_for_alias_top_level(use_solc_version) -> None:
assert False
def test_using_for_alias_contract(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
def test_using_for_alias_contract(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-contract-0.8.0.sol").as_posix(), solc=solc_path
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-contract-0.8.0.sol").as_posix(),
solc=solc_path,
)
contract_c = slither.get_contract_from_name("C")[0]
libCall = contract_c.get_function_from_full_name("libCall(uint256)")
@ -84,9 +89,11 @@ def test_using_for_alias_contract(use_solc_version) -> None:
assert False
def test_using_for_in_library(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.15"))
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-in-library-0.8.0.sol").as_posix(), solc=solc_path)
def test_using_for_in_library(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.15")
slither = Slither(
Path(USING_FOR_TEST_DATA_DIR, "using-for-in-library-0.8.0.sol").as_posix(), solc=solc_path
)
contract_c = slither.get_contract_from_name("A")[0]
libCall = contract_c.get_function_from_full_name("a(uint256)")
for ir in libCall.all_slithir_operations():

@ -1,6 +1,5 @@
from pathlib import Path
from collections import namedtuple
from solc_select import solc_select
from slither import Slither
from slither.slithir.operations import Operation, NewContract
@ -28,11 +27,11 @@ OperationTest = namedtuple("OperationTest", "contract_name slithir_op")
OPERATION_TEST = [OperationTest("NewContract", NewContract)]
def test_operation_reads(use_solc_version) -> None:
def test_operation_reads(solc_binary_path) -> None:
"""
Every slithir operation has its own contract and reads all local and state variables in readAllLocalVariables and readAllStateVariables, respectively.
"""
solc_path = next(use_solc_version("0.8.15"))
solc_path = solc_binary_path("0.8.15")
slither = Slither(Path(TEST_DATA_DIR, "operation_reads.sol").as_posix(), solc=solc_path)
for op_test in OPERATION_TEST:

@ -230,9 +230,8 @@
# assert have_phi_for_var(df, ssa_lvalue)
# @contextmanager
# def slither_from_source(source_code: str, use_solc_version, solc_version: str = "latest"):
# def slither_from_source(source_code: str, solc_binary_path, solc_version: str = "latest"):
# """Yields a Slither instance using source_code string and solc_version
# Creates a temporary file and changes the solc-version temporary to solc_version.
@ -243,7 +242,7 @@
# with NamedTemporaryFile(dir=SCRIPT_DIR, mode="w", suffix=".sol", delete=False) as f:
# fname = f.name
# f.write(source_code)
# solc_path = use_solc_version(solc_version)
# solc_path = solc_binary_path(solc_version)
# yield Slither(fname, solc=solc_path)
# finally:
# pathlib.Path(fname).unlink()

@ -8,9 +8,9 @@ from slither.core.expressions import AssignmentOperation, TupleExpression
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
# pylint: disable=too-many-nested-blocks
def test_ternary_conversions(use_solc_version) -> None:
def test_ternary_conversions(solc_binary_path) -> None:
"""This tests that true and false sons define the same number of variables that the father node declares"""
solc_path = next(use_solc_version("0.8.0"))
solc_path = solc_binary_path("0.8.0")
slither = Slither(Path(TEST_DATA_DIR, "ternary_expressions.sol").as_posix(), solc=solc_path)
for contract in slither.contracts:
for function in contract.functions:

@ -1,5 +1,4 @@
from pathlib import Path
from solc_select import solc_select
from slither import Slither
from slither.utils.code_generation import (
@ -9,8 +8,8 @@ from slither.utils.code_generation import (
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" / "code_generation"
def test_interface_generation(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.4"))
def test_interface_generation(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.4")
sl = Slither(Path(TEST_DATA_DIR, "CodeGeneration.sol").as_posix(), solc=solc_path)

@ -1,5 +1,4 @@
from pathlib import Path
from solc_select import solc_select
from slither import Slither
# % solc functions_ids.sol --hashes
@ -41,8 +40,8 @@ signatures = {
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
def test_functions_ids(use_solc_version) -> None:
solc_path = next(use_solc_version("0.7.0"))
def test_functions_ids(solc_binary_path) -> None:
solc_path = solc_binary_path("0.7.0")
file = Path(TEST_DATA_DIR, "functions_ids.sol").as_posix()
sl = Slither(file, solc=solc_path)
contracts_c = sl.get_contract_from_name("C")

@ -1,12 +1,11 @@
from pathlib import Path
from solc_select import solc_select
from slither import Slither
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"
def test_function_id_rec_structure(use_solc_version) -> None:
solc_path = next(use_solc_version("0.8.0"))
def test_function_id_rec_structure(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
slither = Slither(Path(TEST_DATA_DIR, "type_helpers.sol").as_posix(), solc=solc_path)
for compilation_unit in slither.compilation_units:
for function in compilation_unit.functions:

Loading…
Cancel
Save