From 819202b5845ca4fbd5b04bd1f0665feb764f2856 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 29 Mar 2025 09:30:15 +0000 Subject: [PATCH] minor cleanups --- mmgen/main_txbump.py | 4 ++-- mmgen/proto/eth/tx/status.py | 2 +- test/cmdtest_d/ethdev.py | 3 ++- test/cmdtest_d/ethswap.py | 3 +-- test/cmdtest_d/include/common.py | 6 ++++-- test/cmdtest_d/include/runner.py | 2 ++ test/cmdtest_d/ref.py | 4 ++-- test/cmdtest_d/regtest.py | 5 ++--- test/include/pexpect.py | 3 ++- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index 74be793f..4ac15afd 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -18,7 +18,7 @@ """ mmgen-txbump: Create, and optionally send and sign, a replacement transaction - on networks that support replace-by-fee (RBF) + on supporting networks """ from .cfg import gc, Config @@ -31,7 +31,7 @@ opts_data = { 'text': { 'desc': """ Create, and optionally send and sign, a replacement transaction - on networks that support replace-by-fee (RBF) + on supporting networks """, 'usage2': ( f'[opts] [{gc.proj_name} TX file] [seed source] ...', diff --git a/mmgen/proto/eth/tx/status.py b/mmgen/proto/eth/tx/status.py index 94c5d5d0..add8e08e 100755 --- a/mmgen/proto/eth/tx/status.py +++ b/mmgen/proto/eth/tx/status.py @@ -13,7 +13,7 @@ proto.eth.tx.status: Ethereum transaction status class """ from ....tx import status as TxBase -from ....util import msg, Msg, die, suf, capfirst, pp_fmt +from ....util import msg, Msg, die, suf, capfirst class Status(TxBase.Status): diff --git a/test/cmdtest_d/ethdev.py b/test/cmdtest_d/ethdev.py index ebb009fb..96a727e3 100755 --- a/test/cmdtest_d/ethdev.py +++ b/test/cmdtest_d/ethdev.py @@ -692,6 +692,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared): fee_info_data = ('0.00105', '50'), no_read = False, print_listing = True, + bad_input_sels = True, tweaks = []): fee_info_pat = r'\D{}\D.*{c} .*\D{}\D.*gas price in Gwei'.format(*fee_info_data, c=self.proto.coin) t = self.spawn(f'mmgen-{caller}', self.eth_args + ['-B'] + args) @@ -705,7 +706,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared): input_sels_prompt = 'to spend from', inputs = acct, file_desc = 'transaction', - bad_input_sels = True, + bad_input_sels = bad_input_sels, interactive_fee = interactive_fee, fee_info_pat = fee_info_pat, fee_desc = 'transaction fee or gas price', diff --git a/test/cmdtest_d/ethswap.py b/test/cmdtest_d/ethswap.py index b19c00a7..1d5dac37 100755 --- a/test/cmdtest_d/ethswap.py +++ b/test/cmdtest_d/ethswap.py @@ -17,10 +17,9 @@ from mmgen.cfg import Config from mmgen.protocol import init_proto from .include.runner import CmdTestRunner - from .include.common import dfl_words_file, dfl_seed_id, rt_pw - from .httpd.thornode import ThornodeServer + from .regtest import CmdTestRegtest from .swap import CmdTestSwapMethods from .ethdev import CmdTestEthdev diff --git a/test/cmdtest_d/include/common.py b/test/cmdtest_d/include/common.py index 0fca79fc..4aff6c94 100755 --- a/test/cmdtest_d/include/common.py +++ b/test/cmdtest_d/include/common.py @@ -94,12 +94,14 @@ def confirm_continue(): def randbool(): return getrand(1).hex()[0] in '02468ace' -def get_env_without_debug_vars(): +def cleanup_env(cfg): ret = dict(os.environ) + if cfg.debug_utf8: + return ret for k in cfg._env_opts: if k[:11] == 'MMGEN_DEBUG' and k in ret: del ret[k] - return ret + return ret | {'EXEC_WRAPPER_DO_RUNTIME_MSG': ''} def get_file_with_ext( tdir, diff --git a/test/cmdtest_d/include/runner.py b/test/cmdtest_d/include/runner.py index af35869d..c3813bba 100755 --- a/test/cmdtest_d/include/runner.py +++ b/test/cmdtest_d/include/runner.py @@ -134,6 +134,7 @@ class CmdTestRunner: no_passthru_opts = False, spawn_env_override = None, exit_val = None, + silent = False, env = {}): self.exit_val = exit_val @@ -218,6 +219,7 @@ class CmdTestRunner: pexpect_spawn = pexpect_spawn, timeout = timeout, send_delay = send_delay, + silent = silent, direct_exec = direct_exec) def end_msg(self): diff --git a/test/cmdtest_d/ref.py b/test/cmdtest_d/ref.py index 3e6f6558..2b7bdef8 100755 --- a/test/cmdtest_d/ref.py +++ b/test/cmdtest_d/ref.py @@ -40,7 +40,7 @@ from .include.common import ( pwfile, ref_bw_file_spc, ref_enc_fn, - get_env_without_debug_vars, + cleanup_env, tool_enc_passwd, skip ) @@ -340,7 +340,7 @@ class CmdTestRef(CmdTestBase, CmdTestShared): t = self.spawn( 'mmgen-tool', ['-q', 'decrypt', f, 'outfile='+dec_file, 'hash_preset=1'], - env = os.environ if self.cfg.debug_utf8 else get_env_without_debug_vars()) + env = cleanup_env(self.cfg)) t.passphrase('data', tool_enc_passwd) t.written_to_file('Decrypted data') dec_txt = read_from_file(dec_file) diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 35f5453f..bd82fac9 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -53,7 +53,7 @@ from .include.common import ( tw_comment_lat_cyr_gr, tw_comment_zh, tx_comment_jp, - get_env_without_debug_vars, + cleanup_env, rt_pw) from .base import CmdTestBase @@ -1237,8 +1237,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): ret = self.spawn( 'mmgen-regtest', cmd_args, - env = (os.environ if self.cfg.debug_utf8 else get_env_without_debug_vars()) | ( - {'EXEC_WRAPPER_DO_RUNTIME_MSG': ''}), + env = cleanup_env(self.cfg), no_msg = True ).read().strip() return json.loads(ret) if decode_json else ret diff --git a/test/include/pexpect.py b/test/include/pexpect.py index ab100cbb..1d49d765 100755 --- a/test/include/pexpect.py +++ b/test/include/pexpect.py @@ -47,6 +47,7 @@ class MMGenPexpect: pexpect_spawn = False, send_delay = None, timeout = None, + silent = False, direct_exec = False): self.pexpect_spawn = pexpect_spawn @@ -67,7 +68,7 @@ class MMGenPexpect: else: self.p = PopenSpawn(args, encoding='utf8', timeout=timeout, env=spawn_env) - if cfg.exact_output: + if cfg.exact_output and not silent: self.p.logfile = sys.stdout def do_decrypt_ka_data(