minor fixes and cleanups
This commit is contained in:
parent
2c6473ec3d
commit
55dfcb8f8d
9 changed files with 45 additions and 41 deletions
|
|
@ -36,7 +36,7 @@ class ThornodeRemoteRESTClient(RemoteJSONClient):
|
|||
timeout = 15
|
||||
|
||||
class THORChainRemoteRPCClient(RemoteRPCClient):
|
||||
"communicate with remote THORChain JSON-RPC endpoint"
|
||||
"retrieve data from a remote THORChain JSON-RPC endpoint"
|
||||
|
||||
server_proto = 'THORChain'
|
||||
|
||||
|
|
@ -48,8 +48,14 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
self.rest_api = ThornodeRemoteRESTClient(cfg, proto)
|
||||
self.rpc_api = ThornodeRemoteRPCClient(cfg, proto)
|
||||
|
||||
def acct_info(self, addr: str, *, block=None):
|
||||
"get account information for a given address"
|
||||
return process_response(
|
||||
self.rest_api.get(path=f'/auth/accounts/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')['value']
|
||||
|
||||
def balance(self, addr: str, *, block=None):
|
||||
"get balance for a given address, optionally at a given block height"
|
||||
"get balance for a given address"
|
||||
res = process_response(
|
||||
self.rest_api.get(path=f'/bank/balances/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')
|
||||
|
|
@ -57,14 +63,8 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
assert len(rune_res) == 1, f'{rune_res}: result length is not one!'
|
||||
return self.proto.coin_amt(int(rune_res[0]['amount']), from_unit='satoshi')
|
||||
|
||||
def acct_info(self, addr: str, *, block=None):
|
||||
"get account information for a given address, optionally at a given block height"
|
||||
return process_response(
|
||||
self.rest_api.get(path=f'/auth/accounts/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')['value']
|
||||
|
||||
def tx_info(self, txid: str):
|
||||
"get transaction information for a given TxID"
|
||||
"get information for a transaction by TxID"
|
||||
return process_response(
|
||||
self.rpc_api.post(
|
||||
path = '/tx',
|
||||
|
|
|
|||
|
|
@ -50,17 +50,18 @@ send_tx_parms = namedtuple(
|
|||
'signature'],
|
||||
defaults = (0, None, None, None))
|
||||
|
||||
# superset of swap_tx_parms, differences as noted (##):
|
||||
deposit_tx_parms = namedtuple(
|
||||
'rune_deposit_tx_parms', [
|
||||
'chain',
|
||||
'symbol',
|
||||
'ticker',
|
||||
'chain', ## 'THOR'
|
||||
'symbol', ## 'RUNE'
|
||||
'ticker', ## 'RUNE'
|
||||
'from_addr',
|
||||
'amt',
|
||||
'gas_limit',
|
||||
'account_number',
|
||||
'sequence',
|
||||
'decimals',
|
||||
'decimals', ## 8
|
||||
'memo',
|
||||
'fee', # begin default fields
|
||||
'synth',
|
||||
|
|
|
|||
|
|
@ -152,8 +152,10 @@ def do_pager(text):
|
|||
from subprocess import run
|
||||
for pager in pagers:
|
||||
try:
|
||||
m = text + ('' if pager == 'less' else end_msg)
|
||||
run([pager], input=m.encode(), check=True)
|
||||
run(
|
||||
[pager],
|
||||
input = text.encode() if pager == 'less' else (text + end_msg).encode(),
|
||||
check = True)
|
||||
msg_r('\r')
|
||||
except:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -187,7 +187,10 @@ def indent(s, *, indent=' ', append='\n'):
|
|||
|
||||
def fmt(s, *, indent='', strip_char=None, append='\n'):
|
||||
"de-indent multiple lines of text, or indent with specified string"
|
||||
return indent + ('\n'+indent).join([l.lstrip(strip_char) for l in s.strip().splitlines()]) + append
|
||||
return (
|
||||
indent
|
||||
+ ('\n'+indent).join(l.lstrip(strip_char) for l in s.strip().splitlines())
|
||||
+ append)
|
||||
|
||||
def fmt_list(iterable, *, fmt='dfl', indent='', conv=None):
|
||||
"pretty-format a list"
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ThornodeRPCServer(ThornodeServer):
|
|||
res.update({'hash': 'BD30B8FD9FC278A26E7A81ABB36C4709260DE64087EB578900BD23CEBF11D1A2'})
|
||||
return res
|
||||
|
||||
pat_info = (
|
||||
pat_info = ( # these are matched in order, so more specific patterns must go first
|
||||
('balance', 'GET', r'/bank/balances/(\S+)'),
|
||||
('acct_info', 'GET', r'/auth/accounts/(\S+)'),
|
||||
('tx_info', 'POST', r'/tx$'),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from hashlib import md5
|
|||
|
||||
from mmgen.fileutil import get_data_from_file
|
||||
|
||||
from ..include.common import imsg
|
||||
from .include.common import dfl_words_file
|
||||
from .include.proxy import TestProxy
|
||||
from .ethdev import CmdTestEthdevMethods
|
||||
|
|
@ -101,14 +100,13 @@ class CmdTestRune(CmdTestRuneMethods, CmdTestEthdevMethods, CmdTestBase, CmdTest
|
|||
),
|
||||
'main': (
|
||||
'tracking wallet and transaction operations',
|
||||
('twview', 'viewing unspent outputs in tracking wallet'),
|
||||
('bal_refresh', 'refreshing address balance in tracking wallet'),
|
||||
('txcreate1', 'creating a transaction'),
|
||||
('txsign1', 'signing the transaction'),
|
||||
('txsend1_test', 'testing whether the transaction can be sent'),
|
||||
('txsend1', 'sending the transaction'),
|
||||
('txhex1', 'dumping the transaction hex'))
|
||||
}
|
||||
('twview', 'viewing unspent outputs in tracking wallet'),
|
||||
('bal_refresh', 'refreshing address balance in tracking wallet'),
|
||||
('txcreate1', 'creating a transaction'),
|
||||
('txsign1', 'signing the transaction'),
|
||||
('txsend1_test', 'testing whether the transaction can be sent'),
|
||||
('txsend1', 'sending the transaction'),
|
||||
('txhex1', 'dumping the transaction hex'))}
|
||||
|
||||
def __init__(self, cfg, trunner, cfgs, spawn):
|
||||
CmdTestBase.__init__(self, cfg, trunner, cfgs, spawn)
|
||||
|
|
@ -147,21 +145,23 @@ class CmdTestRune(CmdTestRuneMethods, CmdTestEthdevMethods, CmdTestBase, CmdTest
|
|||
def twview(self):
|
||||
return self.spawn('mmgen-tool', self.rune_opts + self.add_eth_opts + ['twview'])
|
||||
|
||||
def bal_refresh(self):
|
||||
return self._rune_bal_refresh()
|
||||
|
||||
def txcreate1(self):
|
||||
return self._rune_txcreate(add_opts=['--fee=0.2'])
|
||||
|
||||
bal_refresh = CmdTestRuneMethods._rune_bal_refresh
|
||||
txsign1 = CmdTestRuneMethods._rune_txsign
|
||||
_txsend = CmdTestRuneMethods._rune_txsend
|
||||
def txsign1(self):
|
||||
return self._rune_txsign()
|
||||
|
||||
def txsend1_test(self):
|
||||
return self._txsend(add_opts=['--test', f'--proxy=localhost:{TestProxy.port}'], test=True)
|
||||
return self._rune_txsend(add_opts=['--test', f'--proxy=localhost:{TestProxy.port}'], test=True)
|
||||
|
||||
def txsend1(self):
|
||||
return self._txsend()
|
||||
return self._rune_txsend()
|
||||
|
||||
def txhex1(self):
|
||||
t = self._txsend(add_opts=[f'--dump-hex={self.txhex_file}'], dump_hex=True)
|
||||
t = self._rune_txsend(add_opts=[f'--dump-hex={self.txhex_file}'], dump_hex=True)
|
||||
t.read()
|
||||
txhex = get_data_from_file(self.cfg, self.txhex_file, silent=True)
|
||||
if md5(txhex.encode()).hexdigest()[:8] != self.txhex_chksum:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from hashlib import md5
|
|||
|
||||
from mmgen.fileutil import get_data_from_file
|
||||
|
||||
from .httpd.thornode.swap import ThornodeSwapServer
|
||||
from .include.proxy import TestProxy
|
||||
|
||||
from .regtest import CmdTestRegtest
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from mmgen.protocol import init_proto
|
|||
from mmgen.wallet.mmgen import wallet as MMGenWallet
|
||||
from mmgen.tx.file import txfile_json_dumps # pylint: disable=no-name-in-module
|
||||
|
||||
from ..include.common import make_burn_addr, gr_uc
|
||||
from ..include.common import make_burn_addr, gr_uc, imsg
|
||||
|
||||
from .include.runner import CmdTestRunner
|
||||
from .include.common import dfl_words_file
|
||||
|
|
|
|||
|
|
@ -313,16 +313,15 @@ init_tests() {
|
|||
- $cmdtest_py --coin=ltc runeswap
|
||||
"
|
||||
|
||||
[ "$SOC" ] && {
|
||||
xmr_env1="MMGEN_TEST_SUITE_PEXPECT_TIMEOUT=${MMGEN_TEST_SUITE_PEXPECT_TIMEOUT:-600} "
|
||||
xmr_env2="MMGEN_HTTP_TIMEOUT=${MMGEN_HTTP_TIMEOUT:-600} "
|
||||
xmr_env3="MMGEN_DAEMON_STATE_TIMEOUT=${MMGEN_DAEMON_STATE_TIMEOUT:-300} "
|
||||
}
|
||||
[ "$SOC" ] && xmr_env=(
|
||||
"MMGEN_TEST_SUITE_PEXPECT_TIMEOUT=${MMGEN_TEST_SUITE_PEXPECT_TIMEOUT:-600}"
|
||||
"MMGEN_HTTP_TIMEOUT=${MMGEN_HTTP_TIMEOUT:-600}"
|
||||
"MMGEN_DAEMON_STATE_TIMEOUT=${MMGEN_DAEMON_STATE_TIMEOUT:-300}")
|
||||
|
||||
d_xmr="Monero xmrwallet operations"
|
||||
t_xmr="
|
||||
- $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr --exclude help
|
||||
s $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr xmr_autosign_nocompat
|
||||
- ${xmr_env[*]} $cmdtest_py --coin=xmr --exclude help
|
||||
s ${xmr_env[*]} $cmdtest_py --coin=xmr xmr_autosign_nocompat
|
||||
"
|
||||
[ "$FAST" ] && t_xmr_skip='s'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue