From d5078e8ce66a94cd0a5a7a57d1b758f1c8eba86b Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 3 Mar 2021 15:28:29 +0000 Subject: [PATCH] autosign: whitespace, test code cleanups --- mmgen/main_autosign.py | 32 ++++++++++-------- test/test_py_d/ts_autosign.py | 64 +++++++++++++++++------------------ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index 5e00ba52..7961f5ce 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -40,21 +40,23 @@ opts_data = { 'desc': 'Auto-sign MMGen transactions', 'usage':'[opts] [command]', 'options': """ --h, --help Print this help message ---, --longhelp Print help message for long options (common options) --c, --coins=c Coins to sign for (comma-separated list) --I, --no-insert-check Don't check for device insertion --l, --led Use status LED to signal standby, busy and error --m, --mountpoint=m Specify an alternate mountpoint (default: '{mp}') --n, --no-summary Don't print a transaction summary --s, --stealth-led Stealth LED mode - signal busy and error only, and only - after successful authorization. --S, --full-summary Print a full summary of each signed transaction after - each autosign run. The default list of non-MMGen outputs - will not be printed. --q, --quiet Produce quieter output --v, --verbose Produce more verbose output -""".format(mp=mountpoint), +-h, --help Print this help message +--, --longhelp Print help message for long options (common options) +-c, --coins=c Coins to sign for (comma-separated list) +-I, --no-insert-check Don’t check for device insertion +-l, --led Use status LED to signal standby, busy and error +-m, --mountpoint=M Specify an alternate mountpoint 'M' (default: '{mp}') +-n, --no-summary Don’t print a transaction summary +-s, --stealth-led Stealth LED mode - signal busy and error only, and only + after successful authorization. +-S, --full-summary Print a full summary of each signed transaction after + each autosign run. The default list of non-MMGen outputs + will not be printed. +-q, --quiet Produce quieter output +-v, --verbose Produce more verbose output +""".format( + mp = mountpoint + ), 'notes': """ COMMANDS diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index 356873de..2b8f3eca 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -67,12 +67,21 @@ class TestSuiteAutosign(TestSuiteBase): if self.skip_for_win(): return 'skip' - def make_wallet(opts): - t = self.spawn('mmgen-autosign',opts+['gen_key'],extra_desc='(gen_key)') - t.expect_getend('Wrote key file ') - t.ok() + def gen_key(opts): + if not getattr(self,'key_generated',False): + t = self.spawn('mmgen-autosign',opts+['gen_key'],extra_desc='(gen_key)') + t.expect_getend('Wrote key file ') + t.ok() + self.key_generated = True + + def make_wallet(opts): + + t = self.spawn( + 'mmgen-autosign', + opts + + ['setup'], + extra_desc = '(setup)' ) - t = self.spawn('mmgen-autosign',opts+['setup'],extra_desc='(setup)') t.expect('words: ','3') t.expect('OK? (Y/n): ','\n') mn_file = dfl_words_file @@ -135,6 +144,7 @@ class TestSuiteAutosign(TestSuiteBase): if gen_wallet: if not opt.skip_deps: + gen_key(opts) make_wallet(opts) else: do_mount() @@ -178,50 +188,38 @@ class TestSuiteAutosign(TestSuiteBase): def do_autosign(opts,mountpoint): + def autosign_expect(t,txcount): + t.expect('{} transactions signed'.format(txcount)) + t.expect('2 transactions failed to sign') + t.expect('Waiting') + t.kill(2) + t.req_exit_val = 1 + imsg('') + t.ok() + if not opt.skip_deps: + gen_key(opts) make_wallet(opts) copy_files(mountpoint,include_bad_tx=True) - - t = self.spawn('mmgen-autosign',opts+['--full-summary','wait'],extra_desc='(sign - full summary)') - t.expect('{} transactions signed'.format(txcount)) - t.expect('2 transactions failed to sign') - t.expect('Waiting') - t.kill(2) - t.req_exit_val = 1 - imsg('') - t.ok() + t = self.spawn('mmgen-autosign',opts+['--quiet','wait'],extra_desc='(sign)') + autosign_expect(t,txcount) copy_files(mountpoint,remove_signed_only=True) - t = self.spawn('mmgen-autosign',opts+['--quiet','wait'],extra_desc='(sign)') - t.expect('{} transactions signed'.format(txcount)) - t.expect('2 transactions failed to sign') - t.expect('Waiting') - t.kill(2) - t.req_exit_val = 1 - imsg('') - t.ok() + t = self.spawn('mmgen-autosign',opts+['--full-summary','wait'],extra_desc='(sign - full summary)') + autosign_expect(t,txcount) copy_files(mountpoint,include_bad_tx=True,fdata_in=(('btc',''),)) t = self.spawn( 'mmgen-autosign', opts + ['--quiet','--stealth-led','wait'], extra_desc='(sign - --quiet --stealth-led)' ) - t.expect('2 transactions failed to sign') - t.expect('Waiting') - t.kill(2) - t.req_exit_val = 1 - imsg('') - t.ok() + autosign_expect(t,txcount) copy_files(mountpoint,include_bad_tx=False,fdata_in=(('btc',''),)) - t = self.spawn( - 'mmgen-autosign', - opts + ['--quiet','--led'], - extra_desc='(sign - --quiet --led)' ) + t = self.spawn('mmgen-autosign',opts+['--quiet','--led'],extra_desc='(sign - --quiet --led)') t.read() imsg('') - t.ok() return t