test suite: minor fixes and cleanups
This commit is contained in:
parent
7293135db8
commit
866aa6035a
6 changed files with 51 additions and 23 deletions
|
|
@ -172,9 +172,13 @@ class CmdTestOpts(CmdTestBase):
|
|||
return self.check_vals(['--minc=7'], (('cfg.minconf', '7'),))
|
||||
|
||||
def opt_good6(self):
|
||||
if cfg.no_altcoin:
|
||||
return 'skip'
|
||||
return self.check_vals(['--coin=xmr'], (('cfg.coin', 'XMR'),))
|
||||
|
||||
def opt_good7(self):
|
||||
if cfg.no_altcoin:
|
||||
return 'skip'
|
||||
return self.check_vals(['--coin', 'xmr'], (('cfg.coin', 'XMR'),))
|
||||
|
||||
def opt_good8(self):
|
||||
|
|
|
|||
|
|
@ -39,9 +39,10 @@ def test_color():
|
|||
|
||||
from mmgen.color import orange
|
||||
for t, c in (
|
||||
('rxvt', 8),
|
||||
('xterm', 8),
|
||||
('rxvt-unicode', 88),
|
||||
('rxvt', 8),
|
||||
('rxvt-88color', 88),
|
||||
('rxvt-256color', 256),
|
||||
('screen-256color', 256),
|
||||
('xterm-256color', 256)):
|
||||
ret = get_terminfo_colors(t)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ from mmgen.daemon import CoinDaemon
|
|||
|
||||
from ..include.common import cfg, qmsg, qmsg_r, vmsg, msg
|
||||
|
||||
def test_flags():
|
||||
d = CoinDaemon(cfg, 'eth')
|
||||
def test_flags(coin):
|
||||
d = CoinDaemon(cfg, coin)
|
||||
vmsg(f'Available opts: {fmt_list(d.avail_opts, fmt="bare")}')
|
||||
vmsg(f'Available flags: {fmt_list(d.avail_flags, fmt="bare")}')
|
||||
vals = namedtuple('vals', ['online', 'no_daemonize', 'keep_cfg_file'])
|
||||
|
|
@ -26,7 +26,7 @@ def test_flags():
|
|||
(['online'], ['keep_cfg_file'], vals(True, False, True)),
|
||||
(['online', 'no_daemonize'], ['keep_cfg_file'], vals(True, True, True)),
|
||||
):
|
||||
d = CoinDaemon(cfg, 'eth', opts=opts, flags=flags)
|
||||
d = CoinDaemon(cfg, coin, opts=opts, flags=flags)
|
||||
assert d.flag.keep_cfg_file == val.keep_cfg_file
|
||||
assert d.opt.online == val.online
|
||||
assert d.opt.no_daemonize == val.no_daemonize
|
||||
|
|
@ -59,6 +59,7 @@ def test_flags_err(ut, d):
|
|||
class unit_tests:
|
||||
|
||||
win_skip = ('start', 'status', 'stop')
|
||||
altcoin_deps = ('flags_eth',)
|
||||
|
||||
def _pre(self):
|
||||
self.daemon_ctrl_args = ['btc', 'btc_tn', 'btc_rt'] if cfg.no_altcoin_deps else ['all']
|
||||
|
|
@ -78,17 +79,25 @@ class unit_tests:
|
|||
return True
|
||||
|
||||
def flags(self, name, ut):
|
||||
|
||||
qmsg_r('Testing flags and opts...')
|
||||
qmsg_r('Testing flags and opts (BTC)...')
|
||||
vmsg('')
|
||||
daemons = test_flags()
|
||||
daemons = test_flags(coin='btc')
|
||||
qmsg('OK')
|
||||
|
||||
qmsg_r('Testing error handling for flags and opts...')
|
||||
vmsg('')
|
||||
test_flags_err(ut, daemons)
|
||||
qmsg('OK')
|
||||
return True
|
||||
|
||||
def flags_eth(self, name, ut):
|
||||
qmsg_r('Testing flags and opts (ETH)...')
|
||||
vmsg('')
|
||||
daemons = test_flags(coin='eth')
|
||||
qmsg('OK')
|
||||
qmsg_r('Testing error handling for flags and opts...')
|
||||
vmsg('')
|
||||
test_flags_err(ut, daemons)
|
||||
qmsg('OK')
|
||||
return True
|
||||
|
||||
def avail(self, name, ut):
|
||||
|
|
|
|||
|
|
@ -122,7 +122,9 @@ class UnitTestHelpers:
|
|||
self.subtest_name = subtest_name
|
||||
|
||||
def skip_msg(self, desc):
|
||||
cfg._util.qmsg(gray(f'Skipping subtest {self.subtest_name.replace("_", "-")!r} for {desc}'))
|
||||
cfg._util.qmsg(gray(
|
||||
f'Skipping {test_type} subtest {self.subtest_name.replace("_", "-")!r} for {desc}'
|
||||
))
|
||||
|
||||
def process_bad_data(self, data, pfx='bad '):
|
||||
if os.getenv('PYTHONOPTIMIZE'):
|
||||
|
|
@ -213,19 +215,24 @@ def run_test(test, subtest=None):
|
|||
)
|
||||
if hasattr(t, '_pre'):
|
||||
t._pre()
|
||||
|
||||
def subtest_skip_msg(name, add_msg):
|
||||
cfg._util.qmsg(gray(
|
||||
'Skipping {} subtest {!r} {}'.format(test_type, name.replace('_', '-'), add_msg)
|
||||
))
|
||||
|
||||
for _subtest in subtests:
|
||||
subtest_disp = _subtest.replace('_', '-')
|
||||
if cfg.no_altcoin_deps and _subtest in altcoin_deps:
|
||||
cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} [--no-altcoin-deps]'))
|
||||
subtest_skip_msg(_subtest, '[--no-altcoin-deps]')
|
||||
continue
|
||||
if sys.platform == 'win32' and _subtest in win_skip:
|
||||
cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for Windows platform'))
|
||||
subtest_skip_msg(_subtest, 'for Windows platform')
|
||||
continue
|
||||
if sys.platform == 'darwin' and _subtest in mac_skip:
|
||||
cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for macOS platform'))
|
||||
subtest_skip_msg(_subtest, 'for macOS platform')
|
||||
continue
|
||||
if platform.machine() == 'aarch64' and _subtest in arm_skip:
|
||||
cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for ARM platform'))
|
||||
subtest_skip_msg(_subtest, 'for ARM platform')
|
||||
continue
|
||||
run_subtest(t, _subtest)
|
||||
if hasattr(t, '_post'):
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ test.modtest_d.ut_dep: dependency unit tests for the MMGen suite
|
|||
No data verification is performed.
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from subprocess import run, PIPE
|
||||
|
||||
from mmgen.util import msg, rmsg, ymsg, gmsg
|
||||
|
|
@ -61,6 +63,10 @@ class unit_tests:
|
|||
return False
|
||||
|
||||
def secp256k1(self, name, ut):
|
||||
cp = run(['python3', './setup.py', 'build_ext', '--inplace'], stdout=PIPE, stderr=PIPE)
|
||||
if cp.stderr:
|
||||
vmsg(cp.stderr.decode())
|
||||
time.sleep(0.5)
|
||||
from mmgen.proto.secp256k1.secp256k1 import pubkey_gen
|
||||
pubkey_gen(bytes.fromhex('deadbeef'*8), 1)
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -164,14 +164,15 @@ init_tests() {
|
|||
d_autosign="transaction autosigning with automount"
|
||||
t_autosign="
|
||||
- $cmdtest_py autosign_clean autosign_automount autosign
|
||||
b $cmdtest_py autosign_clean autosign_automount autosign_btc
|
||||
btc $cmdtest_py autosign_clean autosign_automount autosign_btc
|
||||
- $cmdtest_py --coin=bch autosign_automount
|
||||
s $cmdtest_py --coin=ltc autosign_automount
|
||||
ltc $cmdtest_py --coin=ltc autosign_automount
|
||||
- $cmdtest_py --coin=eth autosign_eth
|
||||
s $cmdtest_py --coin=etc autosign_eth
|
||||
etc $cmdtest_py --coin=etc autosign_eth
|
||||
"
|
||||
if [ "$SKIP_ALT_DEP" ]; then t_autosign_skip='- s'; else t_autosign_skip='b'; fi
|
||||
[ "$FAST" ] && t_autosign_skip+=' s'
|
||||
if [ "$SKIP_ALT_DEP" ]; then t_autosign_skip='- ltc etc'; else t_autosign_skip='btc'; fi
|
||||
[ "$FAST" ] && t_autosign_skip+=' ltc etc'
|
||||
[ "$SKIP_PARITY" ] && t_autosign_skip+=' etc'
|
||||
|
||||
d_autosign_live="transaction and message autosigning (interactive)"
|
||||
t_autosign_live="- $cmdtest_py autosign_live"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue