mirror of https://github.com/ConsenSys/mythril
blockchainethereumsmart-contractssoliditysecurityprogram-analysissecurity-analysissymbolic-execution
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
3 years ago
|
import pytest
|
||
|
import json
|
||
|
import sys
|
||
|
|
||
2 years ago
|
from utils import output_of
|
||
3 years ago
|
from tests import PROJECT_DIR, TESTDATA
|
||
|
|
||
2 years ago
|
|
||
3 years ago
|
MYTH = str(PROJECT_DIR / "myth")
|
||
|
test_data = (
|
||
|
("suicide.sol", [], "0.5.0"),
|
||
3 years ago
|
("overflow.sol", ["balanceOf(address)", "totalSupply()"], "0.5.0"),
|
||
3 years ago
|
(
|
||
|
"ether_send.sol",
|
||
3 years ago
|
[
|
||
|
"crowdfunding()",
|
||
|
"withdrawfunds()",
|
||
|
"owner()",
|
||
|
"balances(address)",
|
||
|
"getBalance()",
|
||
|
],
|
||
3 years ago
|
"0.5.0",
|
||
|
),
|
||
|
)
|
||
|
|
||
|
bytes_test_data = (
|
||
|
("suicide.sol.o", []),
|
||
|
("overflow.sol.o", ["balanceOf(address)", "totalSupply()"]),
|
||
|
(
|
||
|
"ether_send.sol.o",
|
||
|
["crowdfunding()", "withdrawfunds()", "owner()", "balances(address)"],
|
||
|
),
|
||
|
)
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize("file_name, safe_funcs, version", test_data)
|
||
|
def test_analysis(file_name, safe_funcs, version):
|
||
|
file = str(TESTDATA / "input_contracts" / file_name)
|
||
|
command = f"python3 {MYTH} safe-functions {file} --solv {version}"
|
||
2 years ago
|
output = output_of(command)
|
||
3 years ago
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output
|
||
|
for func in safe_funcs:
|
||
|
assert func in output
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize("file_name, safe_funcs", bytes_test_data)
|
||
|
def test_bytecode_analysis(file_name, safe_funcs):
|
||
|
file = str(TESTDATA / "inputs" / file_name)
|
||
|
command = f"python3 {MYTH} safe-functions --bin-runtime -f {file}"
|
||
2 years ago
|
output = output_of(command)
|
||
3 years ago
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output
|