Add more disassebler tests

pull/906/head
Nikhil Parasaram 6 years ago
parent c41a32a3b5
commit d91ae2bc69
  1. 12
      mythril/mythril/mythril_disassembler.py
  2. 3
      tests/mythril/analyzer_test.py
  3. 27
      tests/mythril/mythril_disassembler_test.py

@ -190,15 +190,6 @@ class MythrilDisassembler:
self.sigs, *args, **kwargs
) # just passthru by passing signatures for now
@staticmethod
def disassemble(contract):
"""
:param contract: the Contract
:return: It's disassembly
"""
return contract.get_easm()
@staticmethod
def hash_for_function_signature(func):
"""
@ -219,8 +210,7 @@ class MythrilDisassembler:
or [position, length, array]
:return: The corresponding storage slot and it's value
"""
if params is None:
params = []
params = params or []
(position, length, mappings) = (0, 1, [])
try:
if params[0] == "mapping":

@ -0,0 +1,3 @@
import pytest
fire_lasers_execute = []

@ -1,6 +1,6 @@
import pytest
from mythril.mythril import MythrilConfig, MythrilDisassembler
from mythril.exceptions import CriticalError
storage_test = [
(
@ -20,6 +20,13 @@ storage_test = [
"0x0000000000000000000000000000000000000000000000000000000000000000",
],
),
(
["mapping", "4588934759847", "10"],
[
"45998575720532480608987132552042185415362901038635143236141343153058112000553: "
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
),
(
["4588934759847", "1", "array"],
[
@ -42,3 +49,21 @@ def test_get_data_from_storage(params, ans):
for a, b in zip(outtext, ans):
assert a == b
assert outtext == ans
storage_test_extra_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):
config = MythrilConfig()
config.set_api_rpc_infura()
disassembler = MythrilDisassembler(eth=config.eth, solc_version="0.4.23")
with pytest.raises(CriticalError):
disassembler.get_state_variable_from_storage(
"0x76799f77587738bfeef09452df215b63d2cfb08a", params
)

Loading…
Cancel
Save