mirror of
https://github.com/qilingframework/qiling.git
synced 2026-10-12 02:21:40 +00:00
fix evm conditions check and evm test
This commit is contained in:
+1
-1
Submodule examples/rootfs updated: c6dc930b68...cc5ffbcf6e
@@ -76,6 +76,8 @@ class QlArchEVMEmulator:
|
||||
code: bytes = b'',
|
||||
code_address: Address = None,
|
||||
contract_address: Address = None):
|
||||
if code == b'' and not data:
|
||||
code = self.ql.loader.code
|
||||
if isinstance(data, str):
|
||||
data = bytecode_to_bytes(data)
|
||||
if isinstance(code, str):
|
||||
|
||||
+3
-3
@@ -123,7 +123,7 @@ class Qiling(QlCoreHooks, QlCoreStructs):
|
||||
else:
|
||||
self._ostype = ostype_convert(self._ostype.lower())
|
||||
|
||||
if self._code == None:
|
||||
if self._code == None and not (str(self._argv[0])):
|
||||
self._code = "qilingcode"
|
||||
if self._argv is None:
|
||||
self._argv = ["qilingcode"]
|
||||
@@ -140,9 +140,9 @@ class Qiling(QlCoreHooks, QlCoreStructs):
|
||||
##############
|
||||
if (not self._interpreter and not self._baremetal) and self._code == None:
|
||||
if not os.path.exists(str(self._argv[0])):
|
||||
raise QlErrorFileNotFound("Target binary not found: %s" %(self._argv[0]))
|
||||
raise QlErrorFileNotFound("Target binary not found: %s" % (self._argv[0]))
|
||||
if not os.path.exists(self._rootfs):
|
||||
raise QlErrorFileNotFound("Target rootfs not found")
|
||||
raise QlErrorFileNotFound("Target rootfs not found %s" % (self._rootfs))
|
||||
|
||||
guessed_archtype, guessed_ostype, guessed_archendian = ql_guess_emu_env(self._path)
|
||||
|
||||
|
||||
@@ -13,10 +13,12 @@ class QlLoaderEVM(QlLoader):
|
||||
def __init__(self, ql:Qiling):
|
||||
super(QlLoaderEVM, self).__init__(ql)
|
||||
self.ql = ql
|
||||
|
||||
|
||||
if self.ql.code is None:
|
||||
with open(self.ql.path) as f:
|
||||
self.ql.code = f.read()
|
||||
self.code = f.read()
|
||||
else:
|
||||
self.code = ql.code
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ class EVMTest(unittest.TestCase):
|
||||
self.assertTrue(testcheck.visited_hookinsn)
|
||||
|
||||
def test_underflow_filename(self):
|
||||
ql = Qiling(["rootfs/evm/Hexagon.hex"], archtype="evm", verbose=4)
|
||||
ql = Qiling(["../examples/rootfs/evm/Hexagon.hex"], archtype="evm", verbose=4)
|
||||
|
||||
user1 = ql.arch.evm.create_account(balance=100*10**18)
|
||||
user2 = ql.arch.evm.create_account(balance=100*10**18)
|
||||
@@ -89,7 +89,7 @@ class EVMTest(unittest.TestCase):
|
||||
return ql.run(code=msg2)
|
||||
|
||||
# Deploy runtime code
|
||||
msg0 = ql.arch.evm.create_message(user1, b'', code=ql.code, contract_address=c1)
|
||||
msg0 = ql.arch.evm.create_message(user1, b'', contract_address=c1)
|
||||
ql.run(code=msg0)
|
||||
|
||||
# # SMART CONTRACT DEPENDENT: check balance of user1
|
||||
|
||||
Reference in New Issue
Block a user