minor fixes and cleanups
This commit is contained in:
parent
aaaccc6bad
commit
9400a558ba
3 changed files with 30 additions and 12 deletions
|
|
@ -53,18 +53,30 @@ class Contract:
|
|||
async def code(self):
|
||||
return (await self.rpc.call('eth_getCode', '0x'+self.addr))[2:]
|
||||
|
||||
async def do_call(self, method_sig, method_args='', *, toUnit=False):
|
||||
async def do_call(
|
||||
self,
|
||||
method_sig,
|
||||
method_args = '',
|
||||
*,
|
||||
block = 'pending', # earliest, latest, safe, finalized
|
||||
toUnit = False):
|
||||
|
||||
data = self.create_method_id(method_sig) + method_args
|
||||
|
||||
args = {
|
||||
'to': '0x' + self.addr,
|
||||
'input': '0x' + data}
|
||||
|
||||
if self.cfg.debug:
|
||||
msg('ETH_CALL {}: {}'.format(
|
||||
method_sig,
|
||||
'\n '.join(parse_abi(data))))
|
||||
ret = await self.rpc.call('eth_call', {'to': '0x'+self.addr, 'data': '0x'+data}, 'pending')
|
||||
|
||||
ret = await self.rpc.call('eth_call', args, block)
|
||||
|
||||
await erigon_sleep(self)
|
||||
if toUnit:
|
||||
return int(ret, 16) * self.base_unit
|
||||
else:
|
||||
return ret
|
||||
|
||||
return int(ret, 16) * self.base_unit if toUnit else ret
|
||||
|
||||
def make_tx_in(self, *, gas, gasPrice, nonce, data):
|
||||
assert isinstance(gas, int), f'{type(gas)}: incorrect type for ‘gas’ (must be an int)'
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from subprocess import run, PIPE, DEVNULL
|
|||
from pathlib import Path
|
||||
|
||||
from mmgen.color import red, yellow, blue, cyan, orange, set_vt100
|
||||
from mmgen.util import msg, rmsg, die
|
||||
from mmgen.util import msg, msg_r, rmsg, die
|
||||
from mmgen.proto.eth.misc import compute_contract_addr
|
||||
|
||||
from ..include.common import (
|
||||
|
|
@ -1763,8 +1763,10 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
|
||||
def stop(self):
|
||||
self.spawn(msg_only=True)
|
||||
if not self.cfg.no_daemon_stop:
|
||||
if not stop_test_daemons(self.proto.coin+'_rt', remove_datadir=True):
|
||||
return False
|
||||
if self.cfg.no_daemon_stop:
|
||||
msg_r(f'(leaving {self.daemon.id} daemon running by user request)')
|
||||
imsg('')
|
||||
elif not stop_test_daemons(self.proto.coin+'_rt', remove_datadir=True):
|
||||
return False
|
||||
set_vt100()
|
||||
return 'ok'
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ test.cmdtest_d.ethswap: Ethereum swap tests for the cmdtest.py test suite
|
|||
from subprocess import run, PIPE, DEVNULL
|
||||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.util import rmsg, die
|
||||
from mmgen.util import msg_r, rmsg, die
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.fileutil import get_data_from_file
|
||||
|
||||
|
|
@ -328,7 +328,11 @@ class CmdTestEthSwap(CmdTestSwapMethods, CmdTestRegtest):
|
|||
|
||||
def thornode_server_stop(self):
|
||||
self.spawn(msg_only=True)
|
||||
thornode_server.stop()
|
||||
if self.cfg.no_daemon_stop:
|
||||
msg_r('(leaving thornode server running by user request)')
|
||||
imsg('')
|
||||
else:
|
||||
thornode_server.stop()
|
||||
return 'ok'
|
||||
|
||||
class CmdTestEthSwapEth(CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue