mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
707 B
24 lines
707 B
2 years ago
|
from pathlib import Path
|
||
2 years ago
|
from solc_select import solc_select
|
||
|
|
||
|
from slither import Slither
|
||
|
from slither.utils.code_generation import (
|
||
|
generate_interface,
|
||
|
)
|
||
|
|
||
2 years ago
|
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" / "code_generation"
|
||
2 years ago
|
|
||
|
|
||
|
def test_interface_generation() -> None:
|
||
|
solc_select.switch_global_version("0.8.4", always_install=True)
|
||
|
|
||
2 years ago
|
sl = Slither(Path(TEST_DATA_DIR, "CodeGeneration.sol").as_posix())
|
||
2 years ago
|
|
||
2 years ago
|
actual = generate_interface(sl.get_contract_from_name("TestContract")[0])
|
||
2 years ago
|
expected_path = Path(TEST_DATA_DIR, "TEST_generated_code.sol").as_posix()
|
||
2 years ago
|
|
||
|
with open(expected_path, "r", encoding="utf-8") as file:
|
||
|
expected = file.read()
|
||
|
|
||
|
assert actual == expected
|