From 2cc1fd282cf6eeaa05c7f7a2e0a8561b946a0541 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 18 Apr 2023 18:35:52 +0000 Subject: [PATCH] test.py autosign: relocate do_sign() method to base class --- test/test_py_d/ts_autosign.py | 58 +++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index f722f4c2..e41f9838 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -277,6 +277,35 @@ class TestSuiteAutosignBase(TestSuiteBase): os.unlink(os.path.join( destdir, os.path.basename(fn).replace('rawmsg','sigmsg') )) return 'ok' + def do_sign(self,args,have_msg=False): + t = self.spawn('mmgen-autosign', self.opts + args ) + t.expect( + f'{self.tx_count} transactions signed' if self.tx_count else + 'No unsigned transactions' ) + + if self.bad_tx_count: + t.expect(f'{self.bad_tx_count} transactions failed to sign') + t.req_exit_val = 1 + + if have_msg: + t.expect( + f'{self.good_msg_count} message files{{0,1}} signed' if self.good_msg_count else + 'No unsigned message files', regex=True ) + + if self.bad_msg_count: + t.expect(f'{self.bad_msg_count} message files{{0,1}} failed to sign', regex=True) + t.req_exit_val = 1 + + if 'wait' in args: + t.expect('Waiting') + t.kill(2) + t.req_exit_val = 1 + else: + t.read() + + imsg('') + return t + class TestSuiteAutosign(TestSuiteAutosignBase): 'autosigning transactions for all supported coins' coins = ['btc','bch','ltc','eth'] @@ -314,35 +343,6 @@ class TestSuiteAutosign(TestSuiteAutosignBase): ('stop_daemons', 'stopping daemons'), ) - def do_sign(self,args,have_msg=False): - t = self.spawn('mmgen-autosign', self.opts + args ) - t.expect( - f'{self.tx_count} transactions signed' if self.tx_count else - 'No unsigned transactions' ) - - if self.bad_tx_count: - t.expect(f'{self.bad_tx_count} transactions failed to sign') - t.req_exit_val = 1 - - if have_msg: - t.expect( - f'{self.good_msg_count} message files{{0,1}} signed' if self.good_msg_count else - 'No unsigned message files', regex=True ) - - if self.bad_msg_count: - t.expect(f'{self.bad_msg_count} message files{{0,1}} failed to sign', regex=True) - t.req_exit_val = 1 - - if 'wait' in args: - t.expect('Waiting') - t.kill(2) - t.req_exit_val = 1 - else: - t.read() - - imsg('') - return t - def sign_quiet(self): return self.do_sign(['--quiet','wait'])