mirror of https://github.com/crytic/slither
parent
08d631f6c9
commit
22b9cfc39c
@ -0,0 +1,41 @@ |
||||
// SPDX-License-Identifier: MIT |
||||
pragma solidity ^0.8.13; |
||||
|
||||
import { |
||||
ParentContract |
||||
} from "./ParentContract.sol"; |
||||
|
||||
import { |
||||
MainErrors as Errors |
||||
} from "./../errors/MainErrors.sol"; |
||||
|
||||
|
||||
contract MainContract is ParentContract { |
||||
|
||||
|
||||
function functionWithMainError1(uint256 a, uint256 b) external pure returns (uint256) { |
||||
if (a == b) { |
||||
revert Errors.MainError1(); |
||||
} |
||||
// Add some arithmetic operations here |
||||
return a + b; |
||||
} |
||||
|
||||
function functionWithMainError2(uint256 a, uint256 b) external pure returns (uint256) { |
||||
if (a < b) { |
||||
revert Errors.MainError2(); |
||||
} |
||||
// Add some arithmetic operations here |
||||
return a - b; |
||||
} |
||||
|
||||
function functionWithMainError3(uint256 a, uint256 b) external pure returns (uint256) { |
||||
if (b == 0) { |
||||
revert Errors.MainError3(); |
||||
} |
||||
// Add some arithmetic operations here |
||||
return a * b; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
// SPDX-License-Identifier: MIT |
||||
pragma solidity ^0.8.13; |
||||
|
||||
|
||||
import { |
||||
AccessControlErrors as Errors |
||||
} from "../errors/ParentContractErrors.sol"; |
||||
|
||||
|
||||
contract ParentContract { |
||||
|
||||
|
||||
function functionWithAccessControlErrors1(uint256 a, uint256 b) external pure returns (uint256) { |
||||
if (a == b) { |
||||
revert Errors.AccessControlErrors1(); |
||||
} |
||||
// Add some arithmetic operations here |
||||
return a + b; |
||||
} |
||||
|
||||
function functionWithAccessControlErrors2(uint256 a, uint256 b) external pure returns (uint256) { |
||||
if (a < b) { |
||||
revert Errors.AccessControlErrors2(); |
||||
} |
||||
// Add some arithmetic operations here |
||||
return a - b; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
// SPDX-License-Identifier: MIT |
||||
pragma solidity ^0.8.13; |
||||
|
||||
// TODO: remove unused errors |
||||
library MainErrors { |
||||
error MainError1(); |
||||
error MainError2(); |
||||
error MainError3(); |
||||
} |
@ -0,0 +1,7 @@ |
||||
// SPDX-License-Identifier: MIT |
||||
pragma solidity ^0.8.13; |
||||
|
||||
library AccessControlErrors { |
||||
error AccessControlErrors1(); |
||||
error AccessControlErrors2(); |
||||
} |
@ -0,0 +1,17 @@ |
||||
from pathlib import Path |
||||
from crytic_compile import CryticCompile |
||||
from crytic_compile.platform.solc_standard_json import SolcStandardJson |
||||
|
||||
from slither import Slither |
||||
|
||||
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" |
||||
SCOPE_RENAMING_TEST_DATA_DIR = Path(TEST_DATA_DIR, "scope_with_renaming") |
||||
|
||||
# https://github.com/crytic/slither/issues/2454 |
||||
def test_find_variable_scope_with_renaming(solc_binary_path) -> None: |
||||
solc_path = solc_binary_path("0.8.24") |
||||
standard_json = SolcStandardJson() |
||||
for source_file in SCOPE_RENAMING_TEST_DATA_DIR.rglob("**/*.sol"): |
||||
standard_json.add_source_file(Path(source_file).as_posix()) |
||||
compilation = CryticCompile(standard_json, solc=solc_path) |
||||
Slither(compilation, disallow_partial=True) |
Loading…
Reference in new issue