Browse Source

cmdtest autosign: add no daemon running test

The MMGen Project 1 year ago
parent
commit
21b3fc9a3b
1 changed files with 12 additions and 2 deletions
  1. 12 2
      test/cmdtest_py_d/ct_autosign.py

+ 12 - 2
test/cmdtest_py_d/ct_autosign.py

@@ -460,6 +460,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
 		('sign_no_unsigned_xmronly', 'signing transactions and messages (nothing to sign, XMR-only)'),
 		('wipe_key',                 'wiping the wallet encryption key'),
 		('stop_daemons',             'stopping daemons'),
+		('sign_bad_no_daemon',       'signing transactions (error, no daemons running)'),
 	)
 
 	def __init__(self,trunner,cfgs,spawn):
@@ -672,12 +673,16 @@ class CmdTestAutosign(CmdTestAutosignBase):
 		self.do_umount()
 		return 'ok'
 
-	def do_sign(self, args, have_msg=False):
+	def do_sign(self, args=[], have_msg=False, exc_exit_val=None):
 		tx_desc = Signable.transaction.desc
 		t = self.spawn(
 				'mmgen-autosign',
 				self.opts + args,
-				exit_val = 1 if self.bad_tx_count or (have_msg and self.bad_msg_count) else None)
+				exit_val = exc_exit_val or (1 if self.bad_tx_count or (have_msg and self.bad_msg_count) else None))
+
+		if exc_exit_val:
+			return t
+
 		t.expect(
 			f'{self.tx_count} {tx_desc}{suf(self.tx_count)} signed' if self.tx_count else
 			f'No unsigned {tx_desc}s')
@@ -719,6 +724,11 @@ class CmdTestAutosign(CmdTestAutosignBase):
 	def sign_full_summary_msg(self):
 		return self.do_sign(['--full-summary'], have_msg=True)
 
+	def sign_bad_no_daemon(self):
+		t = self.do_sign(exc_exit_val=2)
+		t.expect('listening on the correct port')
+		return t
+
 	def sign_no_unsigned(self):
 		return self._sign_no_unsigned(
 			coins   = 'BTC',