diff --git a/.circleci/config.yml b/.circleci/config.yml index 8df7960f..1981c40d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ defaults: &defaults # used for new integration testing, and it is build on top of the previous # `mythril/dev_test_environment:0.0.43`, though a bit newer versions, thus # there is a chance that it breaks some small things. - - image: mythril/dev_test_environment:0.0.45 + - image: mythril/mythril-ci version: 2 jobs: @@ -46,7 +46,7 @@ jobs: - run: background: true name: Launch of background geth instance - command: geth --syncmode full --rpc --shh + command: geth --syncmode full --http --http.api="db,eth,net,web3,personal" --shh - run: name: Unit-testing diff --git a/requirements.txt b/requirements.txt index 4bbb3b67..8559022c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ eth-keys>=0.2.0b3,<0.3.0 eth-rlp>=0.1.0 eth-tester==0.1.0b32 eth-typing>=2.0.0 +eth-utils==1.9.0 jinja2>=2.9 mock numpy==1.19.0 diff --git a/setup.py b/setup.py index 0a640d85..2692b827 100755 --- a/setup.py +++ b/setup.py @@ -36,12 +36,13 @@ REQUIRED = [ "plyvel", "eth_abi==1.3.0", "eth-account>=0.1.0a2,<=0.3.0", - "eth-hash>=0.1.0", + "eth-hash<0.3.0", "eth-keyfile>=0.5.1", "eth-keys>=0.2.0b3,<0.3.0", "eth-rlp>=0.1.0", "eth-tester==0.1.0b32", "eth-typing>=2.0.0", + "eth-utils==1.9.0", "coverage", "jinja2>=2.9", "rlp>=1.0.1,<2.0.0", diff --git a/tests/cmd_line_test.py b/tests/cmd_line_test.py index 80bbcdce..749c59be 100644 --- a/tests/cmd_line_test.py +++ b/tests/cmd_line_test.py @@ -21,7 +21,7 @@ class CommandLineToolTestCase(BaseTestCase): def test_disassemble_solidity_file_correctly(self): solidity_file = str(TESTDATA / "input_contracts" / "metacoin.sol") - command = "python3 {} disassemble {}".format(MYTH, solidity_file) + command = "python3 {} disassemble {} --solv 0.5.0".format(MYTH, solidity_file) self.assertIn("2 PUSH1 0x40\n4 MSTORE", output_of(command)) def test_hash_a_function_correctly(self): @@ -43,7 +43,7 @@ class CommandLineToolTestCase(BaseTestCase): def test_analyze(self): solidity_file = str(TESTDATA / "input_contracts" / "origin.sol") - command = "python3 {} analyze {}".format(MYTH, solidity_file) + command = "python3 {} analyze {} --solv 0.5.0".format(MYTH, solidity_file) self.assertIn("115", output_of(command)) def test_analyze_bytecode(self): diff --git a/tests/laser/transaction/create_transaction_test.py b/tests/laser/transaction/create_transaction_test.py index ad39fb77..8ab2533b 100644 --- a/tests/laser/transaction/create_transaction_test.py +++ b/tests/laser/transaction/create_transaction_test.py @@ -9,9 +9,13 @@ import tests from mythril.analysis.security import fire_lasers from mythril.analysis.symbolic import SymExecWrapper +solc_binary = MythrilDisassembler._init_solc_binary("v0.5.0") + def test_create(): - contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol")) + contract = SolidityContract( + str(tests.TESTDATA_INPUTS_CONTRACTS / "calls.sol"), solc_binary=solc_binary + ) laser_evm = svm.LaserEVM({}) @@ -32,7 +36,9 @@ 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=solc_binary + ) sym = SymExecWrapper( contract, diff --git a/tests/mythril/mythril_analyzer_test.py b/tests/mythril/mythril_analyzer_test.py index 2f100ac1..ba844dde 100644 --- a/tests/mythril/mythril_analyzer_test.py +++ b/tests/mythril/mythril_analyzer_test.py @@ -12,7 +12,7 @@ from mock import patch, PropertyMock @patch("mythril.mythril.mythril_analyzer.SymExecWrapper") def test_fire_lasers(mock_sym, mock_fire_lasers, mock_code_info): type(mock_sym.return_value).execution_info = PropertyMock(return_value=[]) - disassembler = MythrilDisassembler(eth=None) + disassembler = MythrilDisassembler(eth=None, solc_version="v0.5.0") disassembler.load_from_solidity( [ str( diff --git a/tests/rpc_test.py b/tests/rpc_test.py index 45fd762a..de899f1f 100644 --- a/tests/rpc_test.py +++ b/tests/rpc_test.py @@ -15,11 +15,6 @@ class RpcTest(BaseTestCase): """""" self.client.close() - def test_eth_coinbase(self): - coinbase = self.client.eth_coinbase() - self.assertTrue(coinbase.startswith("0x"), "coinbase should be a hex string") - self.assertEqual(len(coinbase), 42, "coinbase is a string with length of 42") - def test_eth_blockNumber(self): block_number = self.client.eth_blockNumber() self.assertGreater( diff --git a/tests/solidity_contract_test.py b/tests/solidity_contract_test.py index a90faca5..bde93c20 100644 --- a/tests/solidity_contract_test.py +++ b/tests/solidity_contract_test.py @@ -5,24 +5,26 @@ from mythril.solidity.soliditycontract import SolidityContract from tests import BaseTestCase TEST_FILES = Path(__file__).parent / "testdata/input_contracts" +solc_binary = MythrilDisassembler._init_solc_binary("v0.5.0") 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)) - - code_info = contract.get_source_info(109) + contract = SolidityContract(str(input_file), solc_binary=solc_binary) + code_info = contract.get_source_info(116) self.assertEqual(code_info.filename, str(input_file)) self.assertEqual(code_info.lineno, 14) self.assertEqual(code_info.code, "msg.sender.transfer(2 ether)") 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=solc_binary + ) - code_info = contract.get_source_info(109) + code_info = contract.get_source_info(116) self.assertEqual(code_info.filename, str(input_file)) self.assertEqual(code_info.lineno, 6) @@ -30,7 +32,9 @@ 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=solc_binary + ) code_info = contract.get_source_info(75, constructor=True)