Add documentation and remove pycache

pull/906/head
Nikhil Parasaram 6 years ago
parent 787b4f2ec2
commit 0dcc70fbc5
  1. 19
      mythril/interfaces/cli.py
  2. 2
      mythril/mythril/mythril_config.py
  3. 6
      mythril/mythril/mythril_disassembler.py
  4. BIN
      tests/mythril/__pycache__/mythril_analyzer_test.cpython-36-PYTEST.pyc
  5. BIN
      tests/mythril/__pycache__/mythril_config_test.cpython-36-PYTEST.pyc
  6. BIN
      tests/mythril/__pycache__/mythril_disassembler_test.cpython-36-PYTEST.pyc
  7. BIN
      tests/mythril/__pycache__/mythril_leveldb_test.cpython-36-PYTEST.pyc
  8. 9
      tests/mythril/mythril_disassembler_test.py

@ -28,7 +28,7 @@ from mythril.version import VERSION
log = logging.getLogger(__name__)
def exit_with_error(format_, message):
def exit_with_error(format_: str, message: str) -> None:
"""
:param format_:
@ -42,7 +42,7 @@ def exit_with_error(format_, message):
sys.exit()
def main():
def main() -> None:
"""The main CLI interface entry point."""
parser = argparse.ArgumentParser(
description="Security analysis of Ethereum smart contracts"
@ -59,7 +59,12 @@ if __name__ == "__main__":
main()
def create_parser(parser):
def create_parser(parser: argparse.ArgumentParser) -> None:
"""
Creates the parser by setting all the possible arguments
:param parser: The parser
:return:
"""
parser.add_argument("solidity_file", nargs="*")
commands = parser.add_argument_group("commands")
@ -246,7 +251,13 @@ def create_parser(parser):
parser.add_argument("--epic", action="store_true", help=argparse.SUPPRESS)
def parse_args(parser, args):
def parse_args(parser: argparse.ArgumentParser, args: argparse.Namespace) -> None:
"""
Parses the arguments
:param parser: The parser
:param args: The args
:return:
"""
if args.epic:
path = os.path.dirname(os.path.realpath(__file__))
sys.argv.remove("--epic")

@ -55,7 +55,7 @@ class MythrilConfig:
Default LevelDB path is specified based on OS
dynamic loading is set to infura by default in the file
Returns: LevelDB directory
:return: LevelDB directory
"""
leveldb_fallback_dir = self._get_fallback_dir()

@ -202,9 +202,9 @@ class MythrilDisassembler:
@staticmethod
def hash_for_function_signature(func: str) -> str:
"""
Return function name's corresponding signature hash
Return function names corresponding signature hash
:param func: function name
:return: It's hash signature
:return: Its hash signature
"""
return "0x%s" % utils.sha3(func)[:4].hex()
@ -217,7 +217,7 @@ class MythrilDisassembler:
:param params: The list of parameters
param types: [position, length] or ["mapping", position, key1, key2, ... ]
or [position, length, array]
:return: The corresponding storage slot and it's value
:return: The corresponding storage slot and its value
"""
params = params or []
(position, length, mappings) = (0, 1, [])

@ -45,21 +45,18 @@ def test_get_data_from_storage(params, ans):
outtext = disassembler.get_state_variable_from_storage(
"0x76799f77587738bfeef09452df215b63d2cfb08a", params
).split("\n")
assert len(outtext) == len(ans)
for a, b in zip(outtext, ans):
assert a == b
assert outtext == ans
storage_test_extra_params = [
storage_test_incorrect_params = [
(["1", "2", "3", "4"]),
(["mapping", "1"]),
(["a", "b", "c"]),
]
@pytest.mark.parametrize("params", storage_test_extra_params)
def test_get_data_from_storage_extra_params(params):
@pytest.mark.parametrize("params", storage_test_incorrect_params)
def test_get_data_from_storage_incorrect_params(params):
config = MythrilConfig()
config.set_api_rpc_infura()
disassembler = MythrilDisassembler(eth=config.eth, solc_version="0.4.23")

Loading…
Cancel
Save