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.
101 lines
2.4 KiB
101 lines
2.4 KiB
import json
|
|
|
|
import pytest
|
|
from utils import output_of
|
|
|
|
from tests import PROJECT_DIR, TESTDATA
|
|
|
|
MYTH = str(PROJECT_DIR / "myth")
|
|
|
|
|
|
test_data = (
|
|
# TODO: The commented tests should be sped up!
|
|
# (
|
|
# "destruct.sol",
|
|
# {
|
|
# "TX_COUNT": 5,
|
|
# "MODULE": "AccidentallyKillable",
|
|
# "ISSUE_COUNT": 1,
|
|
# "VERSION": "v0.5.0",
|
|
# },
|
|
# ),
|
|
# (
|
|
# "destruct.sol",
|
|
# {
|
|
# "TX_COUNT": 4,
|
|
# "MODULE": "AccidentallyKillable",
|
|
# "ISSUE_COUNT": 0,
|
|
# "VERSION": "v0.5.0",
|
|
# },
|
|
# ),
|
|
(
|
|
"theft.sol",
|
|
{"TX_COUNT": 4, "MODULE": "EtherThief", "ISSUE_COUNT": 1, "VERSION": "v0.5.0"},
|
|
),
|
|
(
|
|
"theft.sol",
|
|
{"TX_COUNT": 3, "MODULE": "EtherThief", "ISSUE_COUNT": 0, "VERSION": "v0.5.0"},
|
|
),
|
|
(
|
|
"large.sol",
|
|
{
|
|
"TX_COUNT": 11,
|
|
"MODULE": "AccidentallyKillable",
|
|
"ISSUE_COUNT": 1,
|
|
"VERSION": "v0.5.0",
|
|
},
|
|
),
|
|
(
|
|
"large.sol",
|
|
{
|
|
"TX_COUNT": 10,
|
|
"MODULE": "AccidentallyKillable",
|
|
"ISSUE_COUNT": 0,
|
|
"VERSION": "v0.5.0",
|
|
},
|
|
),
|
|
(
|
|
"hash_test.sol",
|
|
{
|
|
"TX_COUNT": 2,
|
|
"MODULE": "AccidentallyKillable",
|
|
"ISSUE_COUNT": 1,
|
|
"VERSION": "v0.4.24",
|
|
},
|
|
),
|
|
(
|
|
"complex.sol",
|
|
{
|
|
"TX_COUNT": 2,
|
|
"MODULE": "AccidentallyKillable",
|
|
"ISSUE_COUNT": 1,
|
|
"VERSION": "v0.5.0",
|
|
},
|
|
),
|
|
(
|
|
"base_case.sol",
|
|
{
|
|
"TX_COUNT": 1,
|
|
"MODULE": "AccidentallyKillable",
|
|
"ISSUE_COUNT": 1,
|
|
"VERSION": "v0.5.0",
|
|
},
|
|
),
|
|
(
|
|
"simple_theft.sol",
|
|
{
|
|
"TX_COUNT": 1,
|
|
"MODULE": "EtherThief",
|
|
"ISSUE_COUNT": 0,
|
|
"VERSION": "v0.5.0",
|
|
},
|
|
),
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("file_name, tx_data", test_data)
|
|
def test_analysis(file_name, tx_data):
|
|
file_path = str(TESTDATA / "input_contracts" / file_name)
|
|
command = f"""python3 {MYTH} analyze {file_path} -t {tx_data["TX_COUNT"]} -o jsonv2 -m {tx_data["MODULE"]} --solver-timeout 60000 --solv {tx_data["VERSION"]} --execution-timeout 300 --enable-summaries"""
|
|
output = json.loads(output_of(command))
|
|
assert len(output[0]["issues"]) == tx_data["ISSUE_COUNT"]
|
|
|