Fix the tests by fixing solc version of them

pull/753/head
Nikhil Parasaram 6 years ago
parent 09191d5768
commit b1ef2953d7
  1. 11
      tests/cmd_line_test.py
  2. 5
      tests/laser/transaction/create_transaction_test.py
  3. 4
      tests/native_test.py
  4. 7
      tests/solidity_contract_test.py
  5. 4
      tests/svm_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))

@ -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"

@ -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}

@ -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)

@ -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}

Loading…
Cancel
Save