Static Analyzer for Solidity
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.
 
 
 
 
slither/tests/unit/utils/test_code_generation.py

22 lines
677 B

from pathlib import Path
from slither import Slither
from slither.utils.code_generation import (
generate_interface,
)
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" / "code_generation"
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)
actual = generate_interface(sl.get_contract_from_name("TestContract")[0])
expected_path = Path(TEST_DATA_DIR, "TEST_generated_code.sol").as_posix()
with open(expected_path, "r", encoding="utf-8") as file:
expected = file.read()
assert actual == expected