From 4f607d224dac9d2fffecbd496394ef1dd6e83e86 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 2 Sep 2026 13:52:44 +0000 Subject: [PATCH] various fixes and cleanups --- mmgen/cfg.py | 3 ++- mmgen/util.py | 6 +++++- test/cmdtest_d/ethbump.py | 3 --- test/cmdtest_d/ethswap.py | 3 --- test/cmdtest_d/rune.py | 5 ++--- test/cmdtest_d/runeswap.py | 3 --- test/cmdtest_d/swap.py | 24 ++++++++++++++---------- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 5a3e826f..03c8bd3c 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -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 diff --git a/mmgen/util.py b/mmgen/util.py index 138ec38d..8d405c4e 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -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(':'): diff --git a/test/cmdtest_d/ethbump.py b/test/cmdtest_d/ethbump.py index 8390498b..451fde10 100755 --- a/test/cmdtest_d/ethbump.py +++ b/test/cmdtest_d/ethbump.py @@ -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',) diff --git a/test/cmdtest_d/ethswap.py b/test/cmdtest_d/ethswap.py index 47cf7a18..07c277d1 100755 --- a/test/cmdtest_d/ethswap.py +++ b/test/cmdtest_d/ethswap.py @@ -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' diff --git a/test/cmdtest_d/rune.py b/test/cmdtest_d/rune.py index 42c18895..72e1d3df 100755 --- a/test/cmdtest_d/rune.py +++ b/test/cmdtest_d/rune.py @@ -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 diff --git a/test/cmdtest_d/runeswap.py b/test/cmdtest_d/runeswap.py index 72bcb1d8..8a4c1bb3 100755 --- a/test/cmdtest_d/runeswap.py +++ b/test/cmdtest_d/runeswap.py @@ -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' diff --git a/test/cmdtest_d/swap.py b/test/cmdtest_d/swap.py index cf8f818d..a128d518 100755 --- a/test/cmdtest_d/swap.py +++ b/test/cmdtest_d/swap.py @@ -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()