test-release.sh: add separate help test
This commit is contained in:
parent
d8aca5bb6c
commit
d520e31e53
5 changed files with 202 additions and 171 deletions
|
|
@ -145,10 +145,11 @@ seed, the same seed length and hash preset parameters must always be used.
|
|||
|
||||
def txcreate_examples():
|
||||
|
||||
mmtype = 'S' if 'segwit' in proto.caps else 'C'
|
||||
mmtype = 'B' if 'B' in proto.mmtypes else proto.mmtypes[0]
|
||||
from ..tool.coin import tool_cmd
|
||||
t = tool_cmd(cfg,mmtype=mmtype)
|
||||
sample_addr = t.privhex2addr('bead'*16)
|
||||
t = tool_cmd(cfg, mmtype=mmtype)
|
||||
addr = t.privhex2addr('bead' * 16)
|
||||
sample_addr = addr.views[addr.view_pref]
|
||||
|
||||
return f"""
|
||||
EXAMPLES:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ cmd_groups_dfl = {
|
|||
'misc': ('CmdTestMisc',{}),
|
||||
'opts': ('CmdTestOpts',{'full_data':True}),
|
||||
'cfgfile': ('CmdTestCfgFile',{'full_data':True}),
|
||||
'helpscreens': ('CmdTestHelp',{'modname':'misc','full_data':True}),
|
||||
'help': ('CmdTestHelp',{'full_data':True}),
|
||||
'main': ('CmdTestMain',{'full_data':True}),
|
||||
'conv': ('CmdTestWalletConv',{'is3seed':True,'modname':'wallet'}),
|
||||
'ref': ('CmdTestRef',{}),
|
||||
|
|
|
|||
177
test/cmdtest_py_d/ct_help.py
Executable file
177
test/cmdtest_py_d/ct_help.py
Executable file
|
|
@ -0,0 +1,177 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
|
||||
# Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
|
||||
# Licensed under the GNU General Public License, Version 3:
|
||||
# https://www.gnu.org/licenses
|
||||
# Public project repositories:
|
||||
# https://github.com/mmgen/mmgen-wallet
|
||||
# https://gitlab.com/mmgen/mmgen-wallet
|
||||
|
||||
"""
|
||||
test.cmdtest_py_d.ct_help: helpscreen test group for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os, time
|
||||
|
||||
from mmgen.util import ymsg
|
||||
from mmgen.cfg import gc
|
||||
|
||||
from ..include.common import cfg, proto_cmds
|
||||
from .ct_base import CmdTestBase
|
||||
|
||||
class CmdTestHelp(CmdTestBase):
|
||||
'help, info and usage screens'
|
||||
networks = ('btc', 'ltc', 'bch', 'eth', 'xmr', 'doge')
|
||||
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
||||
cmd_group = (
|
||||
('usage', (1,'usage message (via bad invocation)',[])),
|
||||
('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
|
||||
|
|
@ -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',)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
# https://github.com/mmgen/mmgen-wallet
|
||||
# https://gitlab.com/mmgen/mmgen-wallet
|
||||
|
||||
all_tests="dep dev lint obj color unit hash ref altref altgen xmr eth autosign btc btc_tn btc_rt bch bch_tn bch_rt ltc ltc_tn ltc_rt tool tool2 gen alt"
|
||||
all_tests="dep dev lint obj color unit hash ref altref altgen xmr eth autosign btc btc_tn btc_rt bch bch_tn bch_rt ltc ltc_tn ltc_rt tool tool2 gen alt help"
|
||||
|
||||
groups_desc="
|
||||
default - All tests minus the extra tests
|
||||
|
|
@ -19,10 +19,10 @@ groups_desc="
|
|||
"
|
||||
|
||||
init_groups() {
|
||||
dfl_tests='dep alt obj color unit hash ref tool tool2 gen autosign btc btc_tn btc_rt altref altgen bch bch_rt ltc ltc_rt eth etc xmr'
|
||||
dfl_tests='dep alt obj color unit hash ref tool tool2 gen help autosign btc btc_tn btc_rt altref altgen bch bch_rt ltc ltc_rt eth etc xmr'
|
||||
extra_tests='dep dev lint autosign_live ltc_tn bch_tn'
|
||||
noalt_tests='dep alt obj color unit hash ref tool tool2 gen autosign btc btc_tn btc_rt'
|
||||
quick_tests='dep alt obj color unit hash ref tool tool2 gen autosign btc btc_rt altref altgen eth etc xmr'
|
||||
noalt_tests='dep alt obj color unit hash ref tool tool2 gen help autosign btc btc_tn btc_rt'
|
||||
quick_tests='dep alt obj color unit hash ref tool tool2 gen help autosign btc btc_rt altref altgen eth etc xmr'
|
||||
qskip_tests='lint btc_tn bch bch_rt ltc ltc_rt'
|
||||
noalt_ok_tests='lint'
|
||||
|
||||
|
|
@ -141,13 +141,22 @@ init_tests() {
|
|||
z # zcash-mini
|
||||
z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds50x
|
||||
"
|
||||
|
||||
[ "$MSYS2" ] && t_altgen_skip='z' # no zcash-mini (golang)
|
||||
[ "$ARM32" ] && t_altgen_skip='z e'
|
||||
[ "$FAST" ] && t_altgen_skip+=' M'
|
||||
# ARM ethkey available only on Arch Linux:
|
||||
[ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_altgen_skip+=' e'
|
||||
|
||||
d_help="helpscreens for selected coins"
|
||||
t_help="
|
||||
- $cmdtest_py --coin=btc help
|
||||
a $cmdtest_py --coin=bch help
|
||||
a $cmdtest_py --coin=eth help
|
||||
a $cmdtest_py --coin=xmr help
|
||||
a $cmdtest_py --coin=doge help:helpscreens help:longhelpscreens
|
||||
"
|
||||
[ "$SKIP_ALT_DEP" ] && t_help_skip='a'
|
||||
|
||||
d_autosign="transaction autosigning with automount"
|
||||
t_autosign="
|
||||
- $cmdtest_py autosign_clean autosign_automount autosign
|
||||
|
|
@ -165,7 +174,7 @@ init_tests() {
|
|||
|
||||
d_btc="overall operations with emulated RPC data (Bitcoin)"
|
||||
t_btc="
|
||||
- $cmdtest_py --exclude regtest,autosign,autosign_clean,autosign_automount,ref_altcoin
|
||||
- $cmdtest_py --exclude regtest,autosign,autosign_clean,autosign_automount,ref_altcoin,help
|
||||
- $cmdtest_py --segwit
|
||||
- $cmdtest_py --segwit-random
|
||||
- $cmdtest_py --bech32
|
||||
|
|
@ -188,7 +197,7 @@ init_tests() {
|
|||
|
||||
d_bch="overall operations with emulated RPC data (Bitcoin Cash Node)"
|
||||
t_bch="
|
||||
- $cmdtest_py --coin=bch --exclude regtest,autosign_automount
|
||||
- $cmdtest_py --coin=bch --exclude regtest,autosign_automount,help
|
||||
- $cmdtest_py --coin=bch --cashaddr=0 ref3_addr
|
||||
"
|
||||
|
||||
|
|
@ -203,7 +212,7 @@ init_tests() {
|
|||
|
||||
d_ltc="overall operations with emulated RPC data (Litecoin)"
|
||||
t_ltc="
|
||||
- $cmdtest_py --coin=ltc --exclude regtest,autosign_automount
|
||||
- $cmdtest_py --coin=ltc --exclude regtest,autosign_automount,help
|
||||
- $cmdtest_py --coin=ltc --segwit
|
||||
- $cmdtest_py --coin=ltc --segwit-random
|
||||
- $cmdtest_py --coin=ltc --bech32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue