mirror of https://github.com/crytic/slither
Compare commits
5 Commits
9e89bbbe69
...
79619f6de2
Author | SHA1 | Date |
---|---|---|
Josselin Feist | 79619f6de2 | 2 weeks ago |
Feist Josselin | 5488d50b75 | 2 weeks ago |
Feist Josselin | 1ae2e9eb36 | 2 weeks ago |
Feist Josselin | 1941e91602 | 2 weeks ago |
Simone | 4b91acd5f5 | 3 weeks ago |
@ -0,0 +1,47 @@ |
||||
interface I{ |
||||
function testFunction(uint a) external ; |
||||
} |
||||
|
||||
contract A{ |
||||
function testFunction() public{} |
||||
} |
||||
|
||||
contract Test{ |
||||
event TestEvent(); |
||||
struct St{ |
||||
uint a; |
||||
} |
||||
error TestError(); |
||||
|
||||
function testFunction(uint a) public {} |
||||
|
||||
|
||||
function testFunctionStructure(St memory s) public {} |
||||
|
||||
function returnEvent() public returns (bytes32){ |
||||
return TestEvent.selector; |
||||
} |
||||
|
||||
function returnError() public returns (bytes4){ |
||||
return TestError.selector; |
||||
} |
||||
|
||||
|
||||
function returnFunctionFromContract() public returns (bytes4){ |
||||
return I.testFunction.selector; |
||||
} |
||||
|
||||
|
||||
function returnFunction() public returns (bytes4){ |
||||
return this.testFunction.selector; |
||||
} |
||||
|
||||
function returnFunctionWithStructure() public returns (bytes4){ |
||||
return this.testFunctionStructure.selector; |
||||
} |
||||
|
||||
function returnFunctionThroughLocaLVar() public returns(bytes4){ |
||||
A a; |
||||
return a.testFunction.selector; |
||||
} |
||||
} |
@ -0,0 +1,32 @@ |
||||
from pathlib import Path |
||||
from slither import Slither |
||||
from slither.slithir.operations import Assignment |
||||
from slither.slithir.variables import Constant |
||||
|
||||
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" |
||||
|
||||
|
||||
func_to_results = { |
||||
"returnEvent()": "16700440330922901039223184000601971290390760458944929668086539975128325467771", |
||||
"returnError()": "224292994", |
||||
"returnFunctionFromContract()": "890000139", |
||||
"returnFunction()": "890000139", |
||||
"returnFunctionWithStructure()": "1430834845", |
||||
"returnFunctionThroughLocaLVar()": "3781905051", |
||||
} |
||||
|
||||
|
||||
def test_enum_max_min(solc_binary_path) -> None: |
||||
solc_path = solc_binary_path("0.8.19") |
||||
slither = Slither(Path(TEST_DATA_DIR, "selector.sol").as_posix(), solc=solc_path) |
||||
|
||||
contract = slither.get_contract_from_name("Test")[0] |
||||
|
||||
for func_name, value in func_to_results.items(): |
||||
f = contract.get_function_from_signature(func_name) |
||||
assignment = f.slithir_operations[0] |
||||
assert ( |
||||
isinstance(assignment, Assignment) |
||||
and isinstance(assignment.rvalue, Constant) |
||||
and assignment.rvalue.value == value |
||||
) |
Loading…
Reference in new issue