xmrwallet: --full-output -> --full-address; add tests

This commit is contained in:
The MMGen Project 2024-04-15 09:48:14 +00:00
commit fe60f42d53
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 15 additions and 15 deletions

View file

@ -66,8 +66,7 @@ opts_data = {
number means higher fee). Valid parameters:
{tp}. If option
is omitted, the default priority will be used
-F, --full-output For list and listview operations, print
addresses in full instead of truncating them
-F, --full-address Print addresses in full instead of truncating
-m, --autosign-mountpoint=P Specify the autosign mountpoint (defaults to
/mnt/mmgen_autosign, implies --autosign)
-b, --rescan-blockchain Rescan the blockchain if wallet fails to sync

View file

@ -105,7 +105,6 @@ tx_priorities = {
def gen_acct_addr_info(self, wallet_data, account, indent=''):
fs = indent + '{I:<3} {A} {U} {B} {L}'
addr_width = 95 if self.cfg.full_output else 17
addrs_data = wallet_data.addrs_data[account]['addresses']
for d in addrs_data:
@ -126,7 +125,7 @@ def gen_acct_addr_info(self, wallet_data, account, indent=''):
ca = CoinAddr(self.proto, addr['address'])
yield fs.format(
I = addr['address_index'],
A = ca.hl() if self.cfg.full_output else ca.fmt(color=True, width=addr_width),
A = ca.hl() if self.cfg.full_address else ca.fmt(color=True, width=addr_width),
U = (red('True ') if addr['used'] else green('False')),
B = fmt_amt(addr['unlocked_balance']),
L = pink(addr['label']))
@ -735,7 +734,7 @@ class MoneroWalletOps:
if not hasattr(self,'stem'):
self.stem = self.name
global uarg, uarg_info, fmt_amt, hl_amt
global uarg, uarg_info, fmt_amt, hl_amt, addr_width
uarg = uarg_tuple
uarg_info = xmrwallet_uarg_info
@ -745,6 +744,8 @@ class MoneroWalletOps:
def hl_amt(amt):
return self.proto.coin_amt(amt,from_unit='atomic').hl()
addr_width = 95 if self.cfg.full_address else 17
id_cur = None
for cls in classes:
if id(cls.check_uopts) != id_cur:
@ -1060,7 +1061,6 @@ class MoneroWalletOps:
gmsg_r('done')
def gen_accts_info(self, accts_data, addrs_data, indent=' '):
addr_width = 95 if self.cfg.full_output else 17
fs = indent + ' {I:<3} {A} {N} {B} {L}'
yield indent + f'Accounts of wallet {self.fn.name}:'
yield fs.format(
@ -1073,7 +1073,7 @@ class MoneroWalletOps:
ca = CoinAddr(self.proto, e['base_address'])
yield fs.format(
I = str(e['account_index']),
A = ca.hl() if self.cfg.full_output else ca.fmt(color=True, width=addr_width),
A = ca.hl() if self.cfg.full_address else ca.fmt(color=True, width=addr_width),
N = red(str(len(addrs_data[i]['addresses'])).ljust(6)),
B = fmt_amt(e['unlocked_balance']),
L = pink(e['label']))
@ -1463,7 +1463,6 @@ class MoneroWalletOps:
class list(sync):
stem = 'sync'
opts = ('full_output',)
def gen_body(self, wallets_data):
for (wallet_fn, wallet_data) in wallets_data.items():
@ -1813,9 +1812,10 @@ class MoneroWalletOps:
addr = ret[self.address_idx]
new_label = f'{self.label} [{make_timestr()}]' if self.label else ''
ca = CoinAddr(self.proto, addr['address'])
msg('\n {a} {b}\n {c} {d}\n {e} {f}'.format(
a = 'Address: ',
b = cyan(addr['address'][:15] + '...'),
b = ca.hl() if self.cfg.full_address else ca.fmt(color=True, width=addr_width),
c = 'Existing label:',
d = pink(addr['label']) if addr['label'] else gray('[none]'),
e = 'New label: ',

View file

@ -454,17 +454,18 @@ class CmdTestXMRWallet(CmdTestBase):
return self.set_label_user('miner', '1:0:0,"Miner’s new primary account label [1:0:0]"', 'updated')
def remove_label_alice(self):
return self.set_label_user('alice', '4:2:2,""', 'removed')
return self.set_label_user('alice', '4:2:2,""', 'removed', add_opts=['--full-address'])
def set_label_alice(self):
return self.set_label_user('alice', '4:2:2,"Alice’s new subaddress label [4:2:2]"', 'set')
def set_label_user(self,user,label_spec,expect):
def set_label_user(self, user, label_spec, expect, add_opts=[]):
data = self.users[user]
cmd_opts = [f'--wallet-dir={data.udir}', f'--daemon=localhost:{data.md.rpc_port}']
t = self.spawn(
'mmgen-xmrwallet',
self.extra_opts
+ add_opts
+ cmd_opts
+ ['label', data.kafile, label_spec]
)
@ -476,10 +477,10 @@ class CmdTestXMRWallet(CmdTestBase):
return self.sync_wallets('alice',add_opts=['--rescan-blockchain'])
def sync_wallets_selected(self):
return self.sync_wallets('alice',wallets='1-2,4')
return self.sync_wallets('alice', wallets='1-2,4', add_opts=['--full-address'])
def list_wallets_all(self):
return self.sync_wallets('alice',op='list')
return self.sync_wallets('alice', op='list', add_opts=['--full-address'])
def sync_wallets(self,user,op='sync',wallets=None,add_opts=[],bal_chk_func=None):
data = self.users[user]
@ -587,7 +588,7 @@ class CmdTestXMRWallet(CmdTestBase):
return self.mine_chk('alice', 2, 0, lambda x: x.ub > 1, 'unlocked balance > 1')
def sweep_to_wallet_account(self):
self.do_op('sweep', 'alice', '2:0,3:0', use_existing=True)
self.do_op('sweep', 'alice', '2:0,3:0', use_existing=True, add_opts=['--full-address'])
return self.mine_chk('alice', 3, 0, lambda x: x.ub > 1, 'unlocked balance > 1')
def sweep_to_wallet_account_proxy(self):
@ -610,7 +611,7 @@ class CmdTestXMRWallet(CmdTestBase):
async def transfer_to_miner_noproxy(self):
addr = read_from_file(self.users['miner'].addrfile_fs.format(2))
self.do_op('transfer','alice',f'2:1:{addr},0.0995',self.tx_relay_daemon_parm)
self.do_op('transfer', 'alice', f'2:1:{addr},0.0995', self.tx_relay_daemon_parm, add_opts=['--full-address'])
await self.mine_chk('miner',2,0,lambda x: str(x.ub) == '0.2345','unlocked balance == 0.2345')
ok()
return await self.mine_chk('alice',2,1,lambda x: x.ub > 0.9,'unlocked balance > 0.9')