From 5f9494b979b56dc3e28333508e546321cc224cb4 Mon Sep 17 00:00:00 2001 From: Joran Honig Date: Wed, 24 Oct 2018 17:16:19 +0200 Subject: [PATCH] fix missing environments --- tests/analysis/test_delegatecall.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/analysis/test_delegatecall.py b/tests/analysis/test_delegatecall.py index 9e88c1fd..324792e1 100644 --- a/tests/analysis/test_delegatecall.py +++ b/tests/analysis/test_delegatecall.py @@ -1,6 +1,7 @@ from mythril.analysis.modules.delegatecall import execute, _concrete_call, _symbolic_call from mythril.analysis.ops import Call, Variable, VarType from mythril.analysis.symbolic import SymExecWrapper +from mythril.disassembler.disassembly import Disassembly from mythril.laser.ethereum.cfg import Node from mythril.laser.ethereum.state import GlobalState, Environment, Account import pytest @@ -11,8 +12,11 @@ import pytest_mock def test_concrete_call(): # arrange address = "0x10" + active_account = Account(address) + active_account.code = Disassembly("00") + environment = Environment(active_account, None, None, None, None, None) - state = GlobalState(None, None, None) + state = GlobalState(None, environment, None) state.mstate.memory = ["placeholder", "calldata_bling_0"] node = Node("example") @@ -43,7 +47,10 @@ def test_concrete_call_symbolic_to(): # arrange address = "0x10" - state = GlobalState(None, None, None) + active_account = Account(address) + active_account.code = Disassembly("00") + environment = Environment(active_account, None, None, None, None, None) + state = GlobalState(None, environment, None) state.mstate.memory = ["placeholder", "calldata_bling_0"] node = Node("example") @@ -88,6 +95,7 @@ def test_symbolic_call_storage_to(mocker): address = "0x10" active_account = Account(address) + active_account.code = Disassembly("00") environment = Environment(active_account, None, None, None, None, None) state = GlobalState(None, environment, None) state.mstate.memory = ["placeholder", "calldata_bling_0"] @@ -127,7 +135,10 @@ def test_symbolic_call_calldata_to(mocker): # arrange address = "0x10" - state = GlobalState(None, None, None) + active_account = Account(address) + active_account.code = Disassembly("00") + environment = Environment(active_account, None, None, None, None, None) + state = GlobalState(None, environment, None) state.mstate.memory = ["placeholder", "calldata_bling_0"] @@ -172,6 +183,8 @@ def test_delegate_call(sym_mock, concrete_mock, curr_instruction): curr_instruction.return_value = {'address': '0x10'} active_account = Account('0x10') + active_account.code = Disassembly("00") + environment = Environment(active_account, None, None, None, None, None) state = GlobalState(None, environment, Node) state.mstate.memory = ["placeholder", "calldata_bling_0"]