|
@@ -20,11 +20,11 @@
|
|
|
test.cmdtest_py_d.ct_misc: Miscellaneous test groups for the cmdtest.py test suite
|
|
|
"""
|
|
|
|
|
|
-import sys, os, re, time
|
|
|
+import sys, re
|
|
|
|
|
|
-from mmgen.util import ymsg, die
|
|
|
+from mmgen.util import die
|
|
|
|
|
|
-from ..include.common import cfg, start_test_daemons, stop_test_daemons, imsg, proto_cmds
|
|
|
+from ..include.common import cfg, start_test_daemons, stop_test_daemons, imsg
|
|
|
from .common import get_file_with_ext, dfl_words_file
|
|
|
from .ct_base import CmdTestBase
|
|
|
from .ct_main import CmdTestMain
|
|
@@ -179,162 +179,6 @@ class CmdTestMisc(CmdTestBase):
|
|
|
return 'skip'
|
|
|
return self.spawn('test/misc/term_ni.py',['cleanup'],cmd_dir='.',pexpect_spawn=True)
|
|
|
|
|
|
-class CmdTestHelp(CmdTestBase):
|
|
|
- 'help, info and usage screens'
|
|
|
- networks = ('btc','ltc','bch','eth','xmr')
|
|
|
- passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
|
|
- cmd_group = (
|
|
|
- ('usage', (1,'usage message',[])),
|
|
|
- ('version', (1,'version message',[])),
|
|
|
- ('license', (1,'license message',[])),
|
|
|
- ('helpscreens', (1,'help screens', [])),
|
|
|
- ('longhelpscreens', (1,'help screens (--longhelp)',[])),
|
|
|
- ('show_hash_presets', (1,'info screen (--show-hash-presets)',[])),
|
|
|
- ('tool_help', (1,"'mmgen-tool' usage screen",[])),
|
|
|
- ('tool_cmd_usage', (1,"'mmgen-tool' usage screen",[])),
|
|
|
- ('test_help', (1,"'cmdtest.py' help screens",[])),
|
|
|
- ('tooltest_help', (1,"'tooltest.py' help screens",[])),
|
|
|
- )
|
|
|
-
|
|
|
- def usage(self):
|
|
|
- t = self.spawn('mmgen-walletgen', ['foo'], exit_val=1, no_passthru_opts=True)
|
|
|
- t.expect('USAGE: mmgen-walletgen')
|
|
|
- return t
|
|
|
-
|
|
|
- def version(self):
|
|
|
- t = self.spawn('mmgen-tool', ['--version'], exit_val=0)
|
|
|
- t.expect('MMGEN-TOOL version')
|
|
|
- return t
|
|
|
-
|
|
|
- def license(self):
|
|
|
- t = self.spawn(
|
|
|
- 'mmgen-walletconv',
|
|
|
- ['--stdout', '--in-fmt=hex', '--out-fmt=hex'],
|
|
|
- env = {'MMGEN_NO_LICENSE':''},
|
|
|
- no_passthru_opts = True)
|
|
|
- t.expect('to continue: ', 'w')
|
|
|
- t.expect('TERMS AND CONDITIONS') # start of GPL text
|
|
|
- if cfg.pexpect_spawn:
|
|
|
- t.send('G')
|
|
|
- t.expect('return for a fee.') # end of GPL text
|
|
|
- if cfg.pexpect_spawn:
|
|
|
- t.send('q')
|
|
|
- t.expect('to continue: ', 'c')
|
|
|
- t.expect('data: ','beadcafe'*4 + '\n')
|
|
|
- t.expect('to confirm: ', 'YES\n')
|
|
|
- return t
|
|
|
-
|
|
|
- def spawn_chk_expect(self,*args,**kwargs):
|
|
|
- expect = kwargs.pop('expect')
|
|
|
- t = self.spawn(*args,**kwargs)
|
|
|
- t.expect(expect)
|
|
|
- if t.pexpect_spawn:
|
|
|
- time.sleep(0.4)
|
|
|
- t.send('q')
|
|
|
- t.read()
|
|
|
- t.ok()
|
|
|
- t.skip_ok = True
|
|
|
- return t
|
|
|
-
|
|
|
- def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:',pager=True):
|
|
|
-
|
|
|
- scripts = list(scripts) or [s.replace('mmgen-','') for s in os.listdir('cmds')]
|
|
|
-
|
|
|
- if 'tx' not in self.proto.mmcaps:
|
|
|
- scripts = [s for s in scripts if not (s == 'regtest' or s.startswith('tx'))]
|
|
|
-
|
|
|
- if 'xmrwallet' in scripts and (cfg.no_altcoin or not self.proto.coin in ('BTC','XMR')):
|
|
|
- scripts.remove('xmrwallet')
|
|
|
-
|
|
|
- if 'autosign' in scripts and sys.platform == 'win32':
|
|
|
- scripts.remove('autosign')
|
|
|
-
|
|
|
- for cmdname in sorted(scripts):
|
|
|
- t = self.spawn(
|
|
|
- f'mmgen-{cmdname}',
|
|
|
- [arg],
|
|
|
- extra_desc = f'(mmgen-{cmdname})',
|
|
|
- no_passthru_opts = not cmdname in proto_cmds)
|
|
|
- t.expect(expect,regex=True)
|
|
|
- if pager and t.pexpect_spawn:
|
|
|
- time.sleep(0.2)
|
|
|
- t.send('q')
|
|
|
- t.read()
|
|
|
- t.ok()
|
|
|
- t.skip_ok = True
|
|
|
-
|
|
|
- return t
|
|
|
-
|
|
|
- def longhelpscreens(self):
|
|
|
- return self.helpscreens(arg='--longhelp',expect='USAGE:.*LONG OPTIONS:')
|
|
|
-
|
|
|
- def show_hash_presets(self):
|
|
|
- return self.helpscreens(
|
|
|
- arg = '--show-hash-presets',
|
|
|
- scripts = (
|
|
|
- 'walletgen','walletconv','walletchk','passchg','subwalletgen',
|
|
|
- 'addrgen','keygen','passgen',
|
|
|
- 'txsign','txdo','txbump'),
|
|
|
- expect = 'Available parameters.*Preset',
|
|
|
- pager = False )
|
|
|
-
|
|
|
- def tool_help(self):
|
|
|
-
|
|
|
- if os.getenv('PYTHONOPTIMIZE') == '2':
|
|
|
- ymsg('Skipping tool help with PYTHONOPTIMIZE=2 (no docstrings)')
|
|
|
- return 'skip'
|
|
|
-
|
|
|
- for arg in (
|
|
|
- 'help',
|
|
|
- 'usage',
|
|
|
- ):
|
|
|
- t = self.spawn_chk_expect(
|
|
|
- 'mmgen-tool',
|
|
|
- [arg],
|
|
|
- extra_desc = f'(mmgen-tool {arg})',
|
|
|
- expect = 'GENERAL USAGE' )
|
|
|
- return t
|
|
|
-
|
|
|
- def tool_cmd_usage(self):
|
|
|
-
|
|
|
- if os.getenv('PYTHONOPTIMIZE') == '2':
|
|
|
- ymsg('Skipping tool cmd usage with PYTHONOPTIMIZE=2 (no docstrings)')
|
|
|
- return 'skip'
|
|
|
-
|
|
|
- from mmgen.main_tool import mods
|
|
|
-
|
|
|
- for cmdlist in mods.values():
|
|
|
- for cmd in cmdlist:
|
|
|
- t = self.spawn_chk( 'mmgen-tool', ['help',cmd], extra_desc=f'({cmd})' )
|
|
|
- return t
|
|
|
-
|
|
|
- def test_help(self):
|
|
|
- for arg,expect in (
|
|
|
- ('--help','USAGE'),
|
|
|
- ('--list-cmds','AVAILABLE COMMANDS'),
|
|
|
- ('--list-cmd-groups','AVAILABLE COMMAND GROUPS')
|
|
|
- ):
|
|
|
- t = self.spawn_chk_expect(
|
|
|
- 'cmdtest.py',
|
|
|
- [arg],
|
|
|
- cmd_dir = 'test',
|
|
|
- extra_desc = f'(cmdtest.py {arg})',
|
|
|
- expect = expect )
|
|
|
- return t
|
|
|
-
|
|
|
- def tooltest_help(self):
|
|
|
- for arg,expect in (
|
|
|
- ('--list-cmds','Available commands'),
|
|
|
- ('--testing-status','Testing status')
|
|
|
- ):
|
|
|
- t = self.spawn_chk_expect(
|
|
|
- 'tooltest.py',
|
|
|
- [arg],
|
|
|
- cmd_dir = 'test',
|
|
|
- extra_desc = f'(tooltest.py {arg})',
|
|
|
- expect = expect )
|
|
|
- return t
|
|
|
-
|
|
|
class CmdTestOutput(CmdTestBase):
|
|
|
'screen output'
|
|
|
networks = ('btc',)
|