Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert information for echidna #2560

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions slither/printers/guidance/echidna.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,21 @@ def _extract_assert(contracts: List[Contract]) -> Dict[str, Dict[str, List[Dict]
"""
ret: Dict[str, Dict[str, List[Dict]]] = {}
for contract in contracts:
functions_using_assert = [] # Dict[str, List[Dict]] = defaultdict(list)
functions_using_assert: Dict[str, List[Dict]] = defaultdict(list)
for f in contract.functions_entry_points:
for v in f.all_solidity_calls():
if v == SolidityFunction("assert(bool)"):
functions_using_assert.append(_get_name(f))
for node in f.all_nodes():
if SolidityFunction("assert(bool)") in node.solidity_calls and node.source_mapping:
func_name = _get_name(f)
functions_using_assert[func_name].append(node.source_mapping.to_json())
break
# Revert https://github.com/crytic/slither/pull/2105 until format is supported by echidna.
# for node in f.all_nodes():
# if SolidityFunction("assert(bool)") in node.solidity_calls and node.source_mapping:
# func_name = _get_name(f)
# functions_using_assert[func_name].append(node.source_mapping.to_json())
if functions_using_assert:
ret[contract.name] = functions_using_assert
return ret


# Create a named tuple that is serialization in json
def json_serializable(cls):
# pylint: disable=unnecessary-comprehension
# pylint: disable=unnecessary-comprehension,unnecessary-dunder-call
# TODO: the next line is a quick workaround to prevent pylint from crashing
# It can be removed once https://github.com/PyCQA/pylint/pull/3810 is merged
my_super = super
Expand Down
Loading