Browse Source

cmdtest autosign: squelch runtime msg for signing thread

The MMGen Project 8 months ago
parent
commit
cb8b697fe2

+ 3 - 1
mmgen/proto/btc/tx/info.py

@@ -69,6 +69,8 @@ class TxInfo(TxInfo):
 			}[sort]
 			if terse:
 				iwidth = max(len(str(int(e.amt))) for e in io)
+			else:
+				col1_w = len(str(len(io))) + 1
 			for n,e in enumerate(io_sorted()):
 				if is_input and blockcount:
 					confs = e.confs + blockcount - tx.blockcount
@@ -103,7 +105,7 @@ class TxInfo(TxInfo):
 							yield ('',  'confirmations:', f'{confs} (around {days} days)')
 						if not is_input and e.is_chg:
 							yield ('',  'change:',  green('True'))
-					yield '\n'.join('{:>3} {:<8} {}'.format(*d) for d in gen()) + '\n\n'
+					yield '\n'.join('{:>{w}} {:<8} {}'.format(*d,w=col1_w) for d in gen()) + '\n\n'
 
 		addr_w = max(len(e.addr) for f in (tx.inputs,tx.outputs) for e in f)
 

+ 1 - 2
mmgen/tx/completed.py

@@ -27,8 +27,7 @@ class Completed(Base):
 		super().__init__(cfg=cfg,*args,**kwargs)
 
 		if data:
-			data['twctl'] = self.twctl
-			self.__dict__ = data
+			self.__dict__ = data | {'twctl': self.twctl}
 			self.name = type(self).__name__
 		else:
 			from .file import MMGenTxFile

+ 5 - 1
mmgen/util.py

@@ -179,9 +179,13 @@ def pp_fmt(d):
 def pp_msg(d):
 	msg(pp_fmt(d))
 
+def indent(s,indent='    ',append='\n'):
+	"indent multiple lines of text with specified string"
+	return indent + ('\n'+indent).join(s.strip().splitlines()) + append
+
 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.strip(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"

+ 1 - 1
scripts/exec_wrapper.py

@@ -81,7 +81,7 @@ def exec_wrapper_write_traceback(e,exit_val):
 
 def exec_wrapper_end_msg():
 	if (
-		exec_wrapper_os.getenv('EXEC_WRAPPER_SPAWN')
+		exec_wrapper_os.getenv('EXEC_WRAPPER_DO_RUNTIME_MSG')
 		and not exec_wrapper_os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC') ):
 		c = exec_wrapper_get_colors()
 		# write to stdout to ensure script output gets to terminal first

+ 3 - 2
test/cmdtest.py

@@ -590,7 +590,7 @@ class CmdTestRunner:
 			'MMGEN_NO_LICENSE': '1',
 			'MMGEN_BOGUS_SEND': '1',
 			'MMGEN_TEST_SUITE_PEXPECT': '1',
-			'EXEC_WRAPPER_SPAWN':'1',
+			'EXEC_WRAPPER_DO_RUNTIME_MSG':'1',
 			# if cmdtest.py itself is running under exec_wrapper, disable writing of traceback file for spawned script
 			'EXEC_WRAPPER_TRACEBACK': '' if os.getenv('MMGEN_EXEC_WRAPPER') else '1',
 		})
@@ -615,6 +615,7 @@ class CmdTestRunner:
 			pexpect_spawn   = None,
 			direct_exec     = False,
 			no_passthru_opts = False,
+			spawn_env_override = None,
 			env             = {}):
 
 		desc = self.tg.test_name if cfg.names else self.gm.dpy_data[self.tg.test_name][1]
@@ -679,7 +680,7 @@ class CmdTestRunner:
 		send_delay = 0.4 if pexpect_spawn is True or cfg.buf_keypress else None
 		pexpect_spawn = pexpect_spawn if pexpect_spawn is not None else bool(cfg.pexpect_spawn)
 
-		spawn_env = dict(self.tg.spawn_env)
+		spawn_env = dict(spawn_env_override or self.tg.spawn_env)
 		spawn_env.update({
 			'MMGEN_HOLD_PROTECT_DISABLE': '' if send_delay else '1',
 			'MMGEN_TEST_SUITE_POPEN_SPAWN': '' if pexpect_spawn else '1',

+ 2 - 1
test/cmdtest_py_d/ct_autosign.py

@@ -182,7 +182,8 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
 				'mmgen-autosign',
 				self.opts + ['--full-summary','wait'],
 				direct_exec      = True,
-				no_passthru_opts = True)
+				no_passthru_opts = True,
+				spawn_env_override = self.spawn_env | {'EXEC_WRAPPER_DO_RUNTIME_MSG': ''})
 			self.write_to_tmpfile('autosign_thread_pid',str(t.ep.pid))
 		import threading
 		threading.Thread(target=run, name='Autosign wait loop').start()

+ 3 - 2
test/cmdtest_py_d/ct_ethdev.py

@@ -1155,13 +1155,14 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
 	def token_bal1(self):
 		return self.token_bal(n='1')
 
-	def token_txcreate(self,args=[],token='',inputs='1',fee='50G'):
+	def token_txcreate(self,args=[],token='',inputs='1',fee='50G',file_desc='Unsigned transaction'):
 		return self.txcreate_ui_common(
 			self.spawn('mmgen-txcreate', self.eth_args + ['--token='+token,'-B','--fee='+fee] + args),
 			menu              = [],
 			inputs            = inputs,
 			input_sels_prompt = 'to spend from',
-			add_comment       = tx_comment_lat_cyr_gr )
+			add_comment       = tx_comment_lat_cyr_gr,
+			file_desc         = file_desc)
 	def token_txsign(self,ext='',token=''):
 		return self.txsign(ni=True,ext=ext,add_args=['--token='+token])
 	def token_txsend(self,ext='',token=''):