Skip to content

Commit

Permalink
Merge pull request #20 from iamdefinitelyahuman/test/deps
Browse files Browse the repository at this point in the history
Dependencies
  • Loading branch information
iamdefinitelyahuman authored Jul 26, 2021
2 parents 23e3a7b + 0ddebf9 commit 89f0215
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions solcast/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ def set_dependencies(source_nodes):

# convert dependency sets to lists
for contract in contract_list:

if contract in contract.dependencies:
# a contract should not list itself as a dependency
contract.dependencies.remove(contract)

contract.dependencies = sorted(contract.dependencies, key=lambda k: k.name)

return source_nodes


Expand Down
16 changes: 16 additions & 0 deletions tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
JSON_PATHS = list(Path("tests/compiled").glob("*.json"))


def test_dependencies():
ast = solcast.from_standard_output_json("tests/compiled/aragon.json")
node = next(i for i in ast[-1] if i.id == 16359)
deps = set(i.name for i in node.dependencies)
expected = {
"Assert",
"DelegateProxy",
"ERCProxy",
"IsContract",
"ScriptHelpers",
"Target",
"ThrowProxy",
}
assert deps == expected


@pytest.mark.parametrize("path", JSON_PATHS)
def test_solcast(path):
solcast.from_standard_output_json(path)
Expand Down

0 comments on commit 89f0215

Please sign in to comment.