From aee3e7b0ffbaa95d6213807d55957d4f26646dab Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 25 Sep 2019 17:23:14 +0100 Subject: [PATCH] Fix tests --- mythril/laser/ethereum/instructions.py | 4 +--- mythril/laser/ethereum/keccak_function_manager.py | 8 ++++---- mythril/laser/ethereum/state/constraints.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mythril/laser/ethereum/instructions.py b/mythril/laser/ethereum/instructions.py index 48b89814..fb034bae 100644 --- a/mythril/laser/ethereum/instructions.py +++ b/mythril/laser/ethereum/instructions.py @@ -1001,9 +1001,7 @@ class Instruction: # length is 0; this only matters for input of the BitVecFuncVal data = symbol_factory.BitVecVal(0, 1) - result, constraints = keccak_function_manager.create_keccak( - data, length, global_state - ) + result, constraints = keccak_function_manager.create_keccak(data, global_state) state.stack.append(result) state.constraints += constraints diff --git a/mythril/laser/ethereum/keccak_function_manager.py b/mythril/laser/ethereum/keccak_function_manager.py index d673e694..044cc299 100644 --- a/mythril/laser/ethereum/keccak_function_manager.py +++ b/mythril/laser/ethereum/keccak_function_manager.py @@ -47,9 +47,9 @@ class KeccakFunctionManager: self.keccak_vals[func(data)] = keccak return keccak - def create_keccak(self, data: BitVec, length: int, global_state): + def create_keccak(self, data: BitVec, global_state): - length = length * 8 + length = data.size() data = simplify(data) if data.symbolic and simplify(data) not in global_state.topo_keys: if data.size() != 512: @@ -60,7 +60,7 @@ class KeccakFunctionManager: if p1.symbolic and p1 not in global_state.topo_keys: global_state.topo_keys.append(p1) self.keccak_parent[p1] = None - assert length == data.size() + constraints = [] try: func, inverse = self.sizes[length] @@ -78,7 +78,7 @@ class KeccakFunctionManager: self.size_values[length].append(keccak) constraints.append(func(data) == keccak) constraints.append(flag_var) - return func(data), constraints + return keccak, constraints if simplify(func(data)) not in global_state.topo_keys: self.keccak_parent[simplify(func(data))] = data diff --git a/mythril/laser/ethereum/state/constraints.py b/mythril/laser/ethereum/state/constraints.py index fe6513c7..a39e6117 100644 --- a/mythril/laser/ethereum/state/constraints.py +++ b/mythril/laser/ethereum/state/constraints.py @@ -30,7 +30,7 @@ class Constraints(list): super(Constraints, self).__init__(constraint_list) self._default_timeout = 100 self._is_possible = is_possible - self.weighted = [] # type: List[Bool] + self.weighted = [] # type: List[Bool] @property def is_possible(self) -> bool: