Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
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.
mythril/tests/integration_tests/safe_functions_test.py

48 lines
1.4 KiB

import pytest
from utils import output_of
from tests import PROJECT_DIR, TESTDATA
MYTH = str(PROJECT_DIR / "myth")
test_data = (
("suicide.sol", [], "0.5.0"),
("overflow.sol", ["balanceOf(address)", "totalSupply()"], "0.5.0"),
(
"ether_send.sol",
[
"crowdfunding()",
"owner()",
"balances(address)",
"getBalance()",
],
"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}"
output = output_of(command)
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}"
output = output_of(command)
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output