|
|
@ -2,9 +2,10 @@ import pytest |
|
|
|
import json |
|
|
|
import json |
|
|
|
import sys |
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
from subprocess import check_output |
|
|
|
from utils import output_of |
|
|
|
from tests import PROJECT_DIR, TESTDATA |
|
|
|
from tests import PROJECT_DIR, TESTDATA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MYTH = str(PROJECT_DIR / "myth") |
|
|
|
MYTH = str(PROJECT_DIR / "myth") |
|
|
|
test_data = ( |
|
|
|
test_data = ( |
|
|
|
("suicide.sol", [], "0.5.0"), |
|
|
|
("suicide.sol", [], "0.5.0"), |
|
|
@ -36,7 +37,7 @@ bytes_test_data = ( |
|
|
|
def test_analysis(file_name, safe_funcs, version): |
|
|
|
def test_analysis(file_name, safe_funcs, version): |
|
|
|
file = str(TESTDATA / "input_contracts" / file_name) |
|
|
|
file = str(TESTDATA / "input_contracts" / file_name) |
|
|
|
command = f"python3 {MYTH} safe-functions {file} --solv {version}" |
|
|
|
command = f"python3 {MYTH} safe-functions {file} --solv {version}" |
|
|
|
output = check_output(command, shell=True).decode("UTF-8") |
|
|
|
output = output_of(command) |
|
|
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output |
|
|
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output |
|
|
|
for func in safe_funcs: |
|
|
|
for func in safe_funcs: |
|
|
|
assert func in output |
|
|
|
assert func in output |
|
|
@ -46,5 +47,5 @@ def test_analysis(file_name, safe_funcs, version): |
|
|
|
def test_bytecode_analysis(file_name, safe_funcs): |
|
|
|
def test_bytecode_analysis(file_name, safe_funcs): |
|
|
|
file = str(TESTDATA / "inputs" / file_name) |
|
|
|
file = str(TESTDATA / "inputs" / file_name) |
|
|
|
command = f"python3 {MYTH} safe-functions --bin-runtime -f {file}" |
|
|
|
command = f"python3 {MYTH} safe-functions --bin-runtime -f {file}" |
|
|
|
output = check_output(command, shell=True).decode("UTF-8") |
|
|
|
output = output_of(command) |
|
|
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output |
|
|
|
assert f"{len(safe_funcs)} functions are deemed safe in this contract" in output |
|
|
|