diff --git a/tests/cmd_line_test.py b/tests/cmd_line_test.py index 43a6f1b3..c875ffd8 100644 --- a/tests/cmd_line_test.py +++ b/tests/cmd_line_test.py @@ -9,17 +9,22 @@ def output_of(command): class CommandLineToolTestCase(BaseTestCase): + def install_solc_test_version(self): + # This initializes the solc v0.4.24 + command = "python3 {} MYTH -d --solv 0.4.24".format(MYTH) + output_of(command) + def test_disassemble_code_correctly(self): - command = "python3 {} MYTH -d --bin-runtime -c 0x5050".format(MYTH) + command = "python3 {} MYTH -d --bin-runtime -c 0x5050 --solv 0.4.24".format(MYTH) self.assertEqual("0 POP\n1 POP\n", output_of(command)) def test_disassemble_solidity_file_correctly(self): solidity_file = str(TESTDATA / "input_contracts" / "metacoin.sol") - command = "python3 {} -d {}".format(MYTH, solidity_file) + command = "python3 {} -d {} --solv 0.4.24".format(MYTH, solidity_file) self.assertIn("2 PUSH1 0x40\n4 MSTORE", output_of(command)) def test_hash_a_function_correctly(self): - command = "python3 {} --hash 'setOwner(address)'".format(MYTH) + command = "python3 {} --solv 0.4.24 --hash 'setOwner(address)'".format(MYTH) self.assertEqual("0x13af4035\n", output_of(command)) diff --git a/tests/laser/transaction/create_transaction_test.py b/tests/laser/transaction/create_transaction_test.py index 3e319c02..4281378d 100644 --- a/tests/laser/transaction/create_transaction_test.py +++ b/tests/laser/transaction/create_transaction_test.py @@ -1,3 +1,4 @@ +from mythril.mythril import Mythril from mythril.laser.ethereum.transaction import execute_contract_creation from mythril.ethereum import util import mythril.laser.ethereum.svm as svm @@ -10,7 +11,7 @@ from mythril.analysis.symbolic import SymExecWrapper def test_create(): - contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol")) + contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol"), solc_binary=Mythril._init_solc_binary('0.4.24')) laser_evm = svm.LaserEVM({}) @@ -31,7 +32,7 @@ def test_create(): def test_sym_exec(): - contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol")) + contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol"), solc_binary=Mythril._init_solc_binary('0.4.24')) sym = SymExecWrapper( contract, address=(util.get_indexed_address(0)), strategy="dfs" diff --git a/tests/native_test.py b/tests/native_test.py index 01eda4a8..81ca6a4f 100644 --- a/tests/native_test.py +++ b/tests/native_test.py @@ -1,4 +1,5 @@ from mythril.solidity.soliditycontract import SolidityContract +from mythril.mythril import Mythril from mythril.laser.ethereum.state.account import Account from mythril.laser.ethereum.state.machine_state import MachineState from mythril.laser.ethereum.state.global_state import GlobalState @@ -108,7 +109,8 @@ def _test_natives(laser_info, test_list, test_name): class NativeTests(BaseTestCase): @staticmethod def runTest(): - disassembly = SolidityContract("./tests/native_tests.sol").disassembly + + disassembly = SolidityContract("./tests/native_tests.sol", solc_binary=Mythril._init_solc_binary('0.4.24')).disassembly account = Account("0x0000000000000000000000000000000000000000", disassembly) accounts = {account.address: account} diff --git a/tests/solidity_contract_test.py b/tests/solidity_contract_test.py index dd7cc3fb..736309a8 100644 --- a/tests/solidity_contract_test.py +++ b/tests/solidity_contract_test.py @@ -1,5 +1,6 @@ from pathlib import Path +from mythril.mythril import Mythril from mythril.solidity.soliditycontract import SolidityContract from tests import BaseTestCase @@ -9,7 +10,7 @@ TEST_FILES = Path(__file__).parent / "testdata/input_contracts" class SolidityContractTest(BaseTestCase): def test_get_source_info_without_name_gets_latest_contract_info(self): input_file = TEST_FILES / "multi_contracts.sol" - contract = SolidityContract(str(input_file)) + contract = SolidityContract(str(input_file), solc_binary=Mythril._init_solc_binary('0.4.24')) code_info = contract.get_source_info(142) @@ -19,7 +20,7 @@ class SolidityContractTest(BaseTestCase): def test_get_source_info_with_contract_name_specified(self): input_file = TEST_FILES / "multi_contracts.sol" - contract = SolidityContract(str(input_file), name="Transfer1") + contract = SolidityContract(str(input_file), name="Transfer1", solc_binary=Mythril._init_solc_binary('0.4.24')) code_info = contract.get_source_info(142) @@ -29,7 +30,7 @@ class SolidityContractTest(BaseTestCase): def test_get_source_info_with_contract_name_specified_constructor(self): input_file = TEST_FILES / "constructor_assert.sol" - contract = SolidityContract(str(input_file), name="AssertFail") + contract = SolidityContract(str(input_file), name="AssertFail", solc_binary=Mythril._init_solc_binary('0.4.24')) code_info = contract.get_source_info(62, constructor=True) diff --git a/tests/svm_test.py b/tests/svm_test.py index b55ae149..1fdc3bd7 100644 --- a/tests/svm_test.py +++ b/tests/svm_test.py @@ -4,6 +4,8 @@ from mythril.analysis.symbolic import SymExecWrapper from mythril.analysis.callgraph import generate_graph from mythril.ethereum.evmcontract import EVMContract from mythril.solidity.soliditycontract import SolidityContract +from mythril.mythril import Mythril + from mythril.laser.ethereum.state.account import Account from mythril.laser.ethereum.state.machine_state import MachineState @@ -81,7 +83,7 @@ class SVMTestCase(BaseTestCase): input_file.name + ".json" ) - disassembly = SolidityContract(str(input_file)).disassembly + disassembly = SolidityContract(str(input_file), solc_binary=Mythril._init_solc_binary('0.4.24')).disassembly account = Account("0x0000000000000000000000000000000000000000", disassembly) accounts = {account.address: account}