Improve function lookup for bytes (#1163)

* Improve function lookup for bytes

* Update dapp test

* black
pull/1177/head
Feist Josselin 3 years ago committed by GitHub
parent 644f5e59a9
commit 741fc06ea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      scripts/ci_test_dapp.sh
  2. 2
      slither/slithir/convert.py
  3. 17
      tests/ast-parsing/bytes_call.sol
  4. BIN
      tests/ast-parsing/compile/bytes_call.sol-0.8.12-compact.zip
  5. 9
      tests/ast-parsing/expected/bytes_call.sol-0.8.12-compact.json
  6. 1
      tests/test_ast_parsing.py

@ -18,7 +18,7 @@ dapp init
slither . --detect external-function
# TODO: make more elaborate test
if [ $? -eq 3 ]
if [ $? -eq 4 ]
then
exit 0
fi

@ -196,7 +196,7 @@ def _fits_under_byte(val: Union[int, str]) -> List[str]:
return [f"bytes{size}"]
# val is a str
length = len(val.encode("utf-8"))
return [f"bytes{f}" for f in range(length, 33)]
return [f"bytes{f}" for f in range(length, 33)] + ["bytes"]
def _find_function_from_parameter(ir: Call, candidates: List[Function]) -> Optional[Function]:

@ -0,0 +1,17 @@
contract Log{
// Check that we can parse string/bytes
function f(bytes calldata) external{
}
function f(bytes4) external{
}
}
contract A{
Log l;
function test() internal{
l.f("TESTA");
}
}

@ -0,0 +1,9 @@
{
"Log": {
"f(bytes)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n",
"f(bytes4)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n"
},
"A": {
"test()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n}\n"
}
}

@ -403,6 +403,7 @@ ALL_TESTS = [
Test("complex_imports/import_aliases/test.sol", VERSIONS_08),
# 0.8.9 crashes on our testcase
Test("user_defined_types.sol", ["0.8.8"] + make_version(8, 10, 12)),
Test("bytes_call.sol", ["0.8.12"]),
]
# create the output folder if needed
try:

Loading…
Cancel
Save