[WIP]Use latest mythril CI image (#1463)

* Use updated container

* Use geth option

* Use geth option

* Update geth command

* use http flag

* Fix the geth flags

* Remove rpc test and use 0.5.0

* black

* Fix tests for different solc version

* Fix tests for different solc version

* Fix analyzer test

* Fix eth-hash
fix/signextend
Nikhil Parasaram 4 years ago committed by GitHub
parent 9a2572c3d3
commit d8aa12d62b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .circleci/config.yml
  2. 1
      requirements.txt
  3. 3
      setup.py
  4. 4
      tests/cmd_line_test.py
  5. 10
      tests/laser/transaction/create_transaction_test.py
  6. 2
      tests/mythril/mythril_analyzer_test.py
  7. 5
      tests/rpc_test.py
  8. 16
      tests/solidity_contract_test.py

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

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

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

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

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

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

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

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

Loading…
Cancel
Save