Refactor signature DB init, deprecate test DB

pull/785/head
Dominik Muhs 6 years ago
parent 2868db8c28
commit 58d11c792f
  1. 12
      mythril/mythril.py
  2. 10
      tests/__init__.py

@ -17,6 +17,7 @@ from solc.exceptions import SolcError
import solc
from configparser import ConfigParser
import platform
from shutil import copyfile
from mythril.ethereum import util
from mythril.ethereum.evmcontract import EVMContract
@ -116,11 +117,18 @@ class Mythril(object):
except KeyError:
mythril_dir = os.path.join(os.path.expanduser("~"), ".mythril")
# Initialize data directory and signature database
if not os.path.exists(mythril_dir):
# Initialize data directory
logging.info("Creating mythril data directory")
os.mkdir(mythril_dir)
db_path = Path(mythril_dir) / "signatures.db"
if not os.path.exists(db_path):
# if the default mythril dir doesn't contain a signature DB
# initialize it with the default one from the project root
parent_dir = Path(__file__).parent.parent
copyfile(parent_dir / "signatures.db", db_path)
return mythril_dir
def _init_config(self):

@ -18,16 +18,6 @@ MYTHRIL_DIR = TESTS_DIR / "mythril_dir"
class BaseTestCase(TestCase):
def setUp(self):
self.changed_files = []
self.ori_mythril_dir = os.environ.get("MYTHRIL_DIR", "")
os.environ["MYTHRIL_DIR"] = str(MYTHRIL_DIR)
shutil.copyfile(
str(MYTHRIL_DIR / "signatures.db.example"),
str(MYTHRIL_DIR / "signatures.db"),
)
def tearDown(self):
os.environ["MYTHRIL_DIR"] = self.ori_mythril_dir
os.remove(str(MYTHRIL_DIR / "signatures.db"))
def compare_files_error_message(self):
message = "Following output files are changed, compare them manually to see differences: \n"

Loading…
Cancel
Save