various fixes and cleanups

This commit is contained in:
The MMGen Project 2026-09-02 13:52:44 +00:00
commit 4f607d224d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 23 additions and 24 deletions

View file

@ -589,7 +589,8 @@ class Config(Lockable):
if 'sets' in opts_data:
self._set_opts_data_sets_opts(opts_data)
if 'requires' in opts_data: # for required value of None, use False instead
self._check_opts_data_requires_opts(opts_data)
if not {'help', 'longhelp', 'usage'}.intersection(self._uopts):
self._check_opts_data_requires_opts(opts_data)
if 'usage' in self._uopts: # requires self.coin
import importlib

View file

@ -483,7 +483,11 @@ def have_sudo(*, silent=False):
def distro_codename():
if os.path.exists('/etc/os-release'):
with open('/etc/os-release') as fh:
return next(line for line in fh if line.startswith('VERSION_CODENAME=')).rstrip().split('=', 1)[1]
try:
return next(line for line in fh if line.startswith('VERSION_CODENAME=')).rstrip().split('=', 1)[1]
except StopIteration:
pass
return 'none'
def in_nix_environment():
for path in os.getenv('PATH').split(':'):

View file

@ -434,9 +434,6 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthSwapMethods, CmdTestSwapMe
token_swaptxbump1sign = token_swaptxbump2sign = swaptxbump1sign = swaptxbump2sign = token_txbump2sign
token_swaptxbump1send = token_swaptxbump2send = swaptxbump1send = swaptxbump2send = token_txbump2send
def swap_server_stop(self):
return self._thornode_server_stop()
class CmdTestEthBumpLTC(CmdTestSwapMethods, CmdTestRegtest):
'Ethereum transaction bumping operations - LTC wallet'
network = ('ltc',)

View file

@ -311,9 +311,6 @@ class CmdTestEthSwap(CmdTestSwapMethods, CmdTestRegtest):
t.expect('OK? (Y/n): ', 'y')
return self._swaptxcreate_ui_common(t)
def swap_server_stop(self):
return self._thornode_server_stop()
class CmdTestEthSwapEth(CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev):
'Ethereum swap operations - Ethereum wallet'

View file

@ -152,6 +152,5 @@ class CmdTestRune(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
self.tr.warn('txid mismatch')
return t
def rpc_server_stop(self):
return CmdTestSwapMethods._thornode_server_stop(
self, attrname='rpc_server', name='Thornode RPC server')
_thornode_server_stop = CmdTestSwapMethods._thornode_server_stop
rpc_server_stop = CmdTestSwapMethods.rpc_server_stop

View file

@ -83,9 +83,6 @@ class CmdTestRuneSwap(CmdTestSwapMethods, CmdTestRegtest):
TestProxy(self, cfg)
def swap_server_stop(self):
return self._thornode_server_stop()
class CmdTestRuneSwapRune(CmdTestSwapMethods, CmdTestRune):
'RUNE swap operations - RUNE wallet'

View file

@ -249,6 +249,12 @@ class CmdTestSwapMethods:
getattr(self, attrname).stop()
return 'ok'
def swap_server_stop(self):
return self._thornode_server_stop()
def rpc_server_stop(self):
return self._thornode_server_stop(attrname='rpc_server', name='Thornode RPC server')
def create_cross_runner(self, trunner, *, add_cfg={}):
cfg = Config({
'_clone': trunner.cfg,
@ -273,6 +279,7 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
passthru_opts = ('rpc_backend',)
coins = ['bch', 'ltc']
daemon_coins = ['bch', 'ltc']
subseed_idx = '29L'
cmd_group_in = (
('list_assets', 'listing swap assets'),
@ -288,14 +295,14 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
cmd_subgroups = {
'init_swap': (
'Initialize regtest setup for swap operations',
('setup_send_coin', 'setting up the sending coin regtest blockchain'),
('setup_send_coin', 'setting up the sending coin regtest blockchain (BCH)'),
('walletcreate_bob', 'wallet creation (Bob)'),
('addrgen_bob_send', 'address generation (Bob, sending coin)'),
('addrimport_bob_send', 'importing Bob’s addresses (sending coin)'),
('fund_bob_send', 'funding Bob’s wallet (bech32)'),
('bob_bal_send', 'displaying Bob’s send balance'),
('fund_bob_send', 'funding Bob’s wallet (compressed)'),
('bob_bal_send', 'displaying Bob’s send balance (BCH)'),
('setup_recv_coin', 'setting up the receiving coin regtest blockchain'),
('setup_recv_coin', 'setting up the receiving coin regtest blockchain (LTC)'),
('addrgen_bob_recv', 'address generation (Bob, receiving coin)'),
('addrimport_bob_recv', 'importing Bob’s addresses (receiving coin)'),
('fund_bob_recv1', 'funding Bob’s wallet (bech32)'),
@ -303,7 +310,7 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
('addrgen_bob_recv_subwallet', 'address generation (Bob, receiving coin)'),
('addrimport_bob_recv_subwallet', 'importing Bob’s addresses (receiving coin)'),
('fund_bob_recv_subwallet', 'funding Bob’s subwwallet (native Segwit)'),
('bob_bal_recv', 'displaying Bob’s receive balance'),
('bob_bal_recv', 'displaying Bob’s receive balance (LTC)'),
),
'create': (
'Swap TX create operations (BCH => LTC)',
@ -433,10 +440,10 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
return self._fund_bob(0, 'B', '5')
def addrgen_bob_recv_subwallet(self):
return self._addrgen_bob(0, ['C', 'B'], subseed_idx='29L')
return self._addrgen_bob(0, ['C', 'B'], subseed_idx=self.subseed_idx)
def addrimport_bob_recv_subwallet(self):
return self._subwallet_addrimport('bob', '29L', ['C', 'B'], proto=self.protos[0])
return self._subwallet_addrimport('bob', self.subseed_idx, ['C', 'B'], proto=self.protos[0])
def fund_bob_recv_subwallet(self, proto_idx=0, amt='5'):
coin_arg = f'--coin={self.protos[proto_idx].coin}'
@ -683,6 +690,3 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
def mempool1(self):
return self._mempool(1)
def swap_server_stop(self):
return self._thornode_server_stop()