mirror of https://github.com/ConsenSys/mythril
blockchainethereumsmart-contractssoliditysecurityprogram-analysissecurity-analysissymbolic-execution
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
6 years ago
|
from mythril.laser.ethereum.transaction import execute_contract_creation
|
||
6 years ago
|
from mythril.ether import util
|
||
6 years ago
|
import mythril.laser.ethereum.svm as svm
|
||
6 years ago
|
from mythril.disassembler.disassembly import Disassembly
|
||
6 years ago
|
from datetime import datetime
|
||
|
from mythril.ether.soliditycontract import SolidityContract
|
||
|
import tests
|
||
6 years ago
|
from mythril.analysis.security import fire_lasers
|
||
|
from mythril.analysis.symbolic import SymExecWrapper
|
||
6 years ago
|
|
||
|
|
||
|
def test_create():
|
||
|
contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / 'calls.sol'))
|
||
|
|
||
|
laser_evm = svm.LaserEVM({})
|
||
|
|
||
|
laser_evm.time = datetime.now()
|
||
6 years ago
|
execute_contract_creation(laser_evm, contract.creation_code)
|
||
6 years ago
|
|
||
6 years ago
|
resulting_final_state = laser_evm.open_states[0]
|
||
|
|
||
6 years ago
|
for address, created_account in resulting_final_state.accounts.items():
|
||
6 years ago
|
created_account_code = created_account.code
|
||
|
actual_code = Disassembly(contract.code)
|
||
|
|
||
|
for i in range(len(created_account_code.instruction_list)):
|
||
|
found_instruction = created_account_code.instruction_list[i]
|
||
|
actual_instruction = actual_code.instruction_list[i]
|
||
|
|
||
|
assert found_instruction['opcode'] == actual_instruction['opcode']
|
||
6 years ago
|
|
||
|
def test_sym_exec():
|
||
|
contract = SolidityContract(str(tests.TESTDATA_INPUTS_CONTRACTS / 'calls.sol'))
|
||
|
|
||
|
sym = SymExecWrapper(contract, address=(util.get_indexed_address(0)), strategy="dfs")
|
||
|
issues = fire_lasers(sym)
|
||
|
|
||
|
assert len(issues) != 0
|