unit_tests.py: cleanups, import cleanups
This commit is contained in:
parent
18d0b285ee
commit
bbe19effb0
19 changed files with 74 additions and 45 deletions
|
|
@ -30,7 +30,10 @@ if not os.getenv('MMGEN_DEVTOOLS'):
|
|||
from mmgen.devinit import init_dev
|
||||
init_dev()
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.cfg import Config,gc
|
||||
from mmgen.color import gray
|
||||
from mmgen.util import msg,gmsg,ymsg,Msg,die,async_run
|
||||
|
||||
from test.include.common import set_globals,end_msg
|
||||
|
||||
opts_data = {
|
||||
|
|
@ -60,6 +63,9 @@ sys.argv.insert(1,'--skip-cfg-file')
|
|||
|
||||
cfg = Config(opts_data=opts_data)
|
||||
|
||||
if cfg.no_altcoin_deps:
|
||||
ymsg(f'{gc.prog_name}: skipping altcoin tests by user request')
|
||||
|
||||
type(cfg)._reset_ok += ('use_internal_keccak_module','debug_addrlist')
|
||||
|
||||
set_globals(cfg)
|
||||
|
|
@ -132,12 +138,10 @@ tests_seen = []
|
|||
def run_test(test,subtest=None):
|
||||
mod = importlib.import_module(f'test.unit_tests_d.{file_pfx}{test}')
|
||||
|
||||
def run_subtest(subtest):
|
||||
def run_subtest(t,subtest):
|
||||
subtest_disp = subtest.replace('_','-')
|
||||
msg(f'Running unit subtest {test}.{subtest_disp}')
|
||||
|
||||
t = getattr(mod,'unit_tests')()
|
||||
|
||||
if getattr(t,'silence_output',False):
|
||||
t._silence()
|
||||
|
||||
|
|
@ -188,7 +192,7 @@ def run_test(test,subtest=None):
|
|||
elif platform.machine() == 'aarch64' and subtest in arm_skip:
|
||||
cfg._util.qmsg(gray(f'Skipping subtest {subtest_disp!r} for ARM platform'))
|
||||
continue
|
||||
run_subtest(subtest)
|
||||
run_subtest(t,subtest)
|
||||
if hasattr(t,'_post'):
|
||||
t._post()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
test.unit_tests_d.ut_addrlist: address list unit tests for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.color import blue
|
||||
from mmgen.util import msg
|
||||
|
||||
from mmgen.seed import Seed
|
||||
from mmgen.addr import MMGenAddrType
|
||||
from mmgen.addrlist import AddrIdxList,AddrList,KeyList,KeyAddrList,ViewKeyAddrList
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
test/unit_tests_d/ut_addrparse: address parsing tests for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.color import yellow,cyan
|
||||
from mmgen.util import msg,msg_r,pp_fmt
|
||||
|
||||
from ..include.common import cfg,vmsg
|
||||
|
||||
vectors = {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test.unit_tests_d.ut_baseconv: Base conversion unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r
|
||||
|
||||
from ..include.common import cfg,qmsg,qmsg_r,vmsg,vmsg_r
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test/unit_tests_d/ut_bip39: BIP39 unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r
|
||||
|
||||
from ..include.common import cfg,qmsg,vmsg
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
test.unit_tests_d.ut_daemon: unit test for the MMGen suite's Daemon class
|
||||
"""
|
||||
|
||||
from subprocess import run,DEVNULL
|
||||
from mmgen.common import *
|
||||
from mmgen.daemon import *
|
||||
from subprocess import run,DEVNULL,PIPE
|
||||
from collections import namedtuple
|
||||
|
||||
from mmgen.color import orange
|
||||
from mmgen.util import fmt_list
|
||||
from mmgen.daemon import CoinDaemon
|
||||
from mmgen.protocol import init_proto
|
||||
|
||||
from ..include.common import cfg,qmsg,qmsg_r,vmsg
|
||||
|
||||
def test_flags():
|
||||
|
|
@ -53,19 +57,22 @@ def test_flags_err(ut,d):
|
|||
('flag (4)', 'ClassFlagsError', 'already set', bad7 ),
|
||||
))
|
||||
|
||||
def test_cmd(args_in,message):
|
||||
qmsg_r(message)
|
||||
args = ['python3', f'test/{args_in[0]}-coin-daemons.py'] + list(args_in[1:])
|
||||
vmsg('\n' + orange(f"Running '{' '.join(args)}':"))
|
||||
pipe = None if cfg.verbose else PIPE
|
||||
cp = run( args, stdout=pipe, stderr=pipe, check=True )
|
||||
qmsg('OK')
|
||||
return True
|
||||
|
||||
class unit_tests:
|
||||
|
||||
win_skip = ('start','status','stop')
|
||||
|
||||
def _pre(self):
|
||||
self.daemon_ctrl_args = ['btc','btc_tn','btc_rt'] if cfg.no_altcoin_deps else ['all']
|
||||
|
||||
def _test_cmd(self,args_in,message):
|
||||
qmsg_r(message)
|
||||
args = ['python3', f'test/{args_in[0]}-coin-daemons.py'] + list(args_in[1:]) + self.daemon_ctrl_args
|
||||
vmsg('\n' + orange(f"Running '{' '.join(args)}':"))
|
||||
pipe = None if cfg.verbose else PIPE
|
||||
cp = run( args, stdout=pipe, stderr=pipe, check=True )
|
||||
qmsg('OK')
|
||||
return True
|
||||
|
||||
def flags(self,name,ut):
|
||||
|
||||
qmsg_r('Testing flags and opts...')
|
||||
|
|
@ -81,16 +88,16 @@ class unit_tests:
|
|||
return True
|
||||
|
||||
def exec(self,name,ut):
|
||||
return test_cmd(['start','-Vm','all'], 'Testing availability of coin daemons...')
|
||||
return self._test_cmd(['start','-Vm'], 'Testing availability of coin daemons...')
|
||||
|
||||
def cmds(self,name,ut):
|
||||
return test_cmd(['start','-t','all'], 'Testing start commands for coin daemons...')
|
||||
return self._test_cmd(['start','-t'], 'Testing start commands for coin daemons...')
|
||||
|
||||
def start(self,name,ut):
|
||||
return test_cmd(['start','all'], 'Starting coin daemons...')
|
||||
return self._test_cmd(['start'], 'Starting coin daemons...')
|
||||
|
||||
def status(self,name,ut):
|
||||
return test_cmd(['start','all'], 'Checking status of coin daemons...')
|
||||
return self._test_cmd(['start'], 'Checking status of coin daemons...')
|
||||
|
||||
def stop(self,name,ut):
|
||||
return test_cmd(['stop','all'], 'Stopping coin daemons...')
|
||||
return self._test_cmd(['stop'], 'Stopping coin daemons...')
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite
|
|||
|
||||
from subprocess import run,PIPE
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import ymsg,gmsg
|
||||
from mmgen.exception import NoLEDSupport
|
||||
|
||||
from ..include.common import cfg,vmsg,check_solc_ver
|
||||
|
||||
class unit_tests:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
test.unit_tests_d.ut_flags: unit test for the MMGen suite's ClassFlags class
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.flags import *
|
||||
from mmgen.flags import ClassOpts,ClassFlags
|
||||
|
||||
from ..include.common import qmsg,qmsg_r,vmsg
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@
|
|||
test.unit_tests_d.ut_gen: key/address generation unit tests for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.color import blue
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.key import PrivKey
|
||||
from mmgen.addr import MMGenAddrType
|
||||
from mmgen.addrgen import KeyGenerator,AddrGenerator
|
||||
from mmgen.keygen import get_backends
|
||||
|
||||
from ..include.common import cfg,qmsg
|
||||
|
||||
# TODO: add viewkey checks
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test/unit_tests_d/ut_indexed_dict: IndexedDict class unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r,die
|
||||
|
||||
from ..include.common import vmsg
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
test.unit_tests_d.ut_lockable: unit test for the MMGen suite's Lockable class
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from ..include.common import qmsg,qmsg_r,vmsg
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ test.unit_tests_d.ut_obj: data object unit tests for the MMGen suite
|
|||
|
||||
from decimal import Decimal
|
||||
|
||||
from mmgen.common import *
|
||||
from ..include.common import qmsg,qmsg_r,vmsg
|
||||
|
||||
class unit_tests:
|
||||
|
|
|
|||
|
|
@ -4,15 +4,17 @@
|
|||
test.unit_tests_d.ut_rpc: RPC unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from mmgen.common import *
|
||||
import os,time
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.color import yellow,cyan
|
||||
from mmgen.util import msg,gmsg,async_run,make_timestr,pp_fmt,die
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.rpc import rpc_init
|
||||
from mmgen.daemon import CoinDaemon
|
||||
from mmgen.proto.xmr.rpc import MoneroRPCClient,MoneroWalletRPCClient
|
||||
from mmgen.proto.xmr.daemon import MoneroWalletDaemon
|
||||
|
||||
from ..include.common import cfg,qmsg,vmsg
|
||||
|
||||
def cfg_file_auth_test(proto,d,bad_auth=False):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test/unit_tests_d/ut_seedsplit: seed splitting unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r
|
||||
|
||||
from ..include.common import cfg,vmsg,vmsg_r
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test/unit_tests_d/ut_subseed: subseed unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r
|
||||
|
||||
from ..include.common import cfg,vmsg_r
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@
|
|||
test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
import os
|
||||
from subprocess import run,PIPE
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import ymsg
|
||||
|
||||
sec = 'deadbeef' * 8
|
||||
|
||||
class unit_tests:
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
test.unit_tests_d.ut_tx: TX unit tests for the MMGen suite
|
||||
"""
|
||||
|
||||
import re
|
||||
import os,re
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.tx import NewTX,CompletedTX
|
||||
from mmgen.tx.file import MMGenTxFile
|
||||
from mmgen.daemon import CoinDaemon
|
||||
from mmgen.protocol import init_proto
|
||||
|
||||
from ..include.common import cfg,qmsg,vmsg
|
||||
|
||||
async def do_txfile_test(desc,fns):
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@ test/unit_tests_d/ut_tx_deserialize: TX deserialization unit tests for the MMGen
|
|||
|
||||
import os,json
|
||||
|
||||
from mmgen.common import *
|
||||
from ..include.common import cfg,start_test_daemons,stop_test_daemons
|
||||
from mmgen.util import msg,Msg,Msg_r
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.tx import CompletedTX
|
||||
from mmgen.proto.btc.tx.base import DeserializeTX
|
||||
from mmgen.rpc import rpc_init
|
||||
from mmgen.daemon import CoinDaemon
|
||||
|
||||
from ..include.common import cfg,start_test_daemons,stop_test_daemons
|
||||
|
||||
def print_info(name,extra_desc):
|
||||
if cfg.names:
|
||||
Msg_r('{} {} {}'.format(
|
||||
|
|
@ -106,7 +107,8 @@ class unit_tests:
|
|||
|
||||
core_repo_root = os.getenv('CORE_REPO_ROOT')
|
||||
if not core_repo_root:
|
||||
die(1,'The environmental variable CORE_REPO_ROOT must be set before running this test')
|
||||
msg('The environmental variable CORE_REPO_ROOT must be set before running this test')
|
||||
return False
|
||||
|
||||
start_test_daemons('btc')
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
test/unit_tests_d/ut_xmrseed: Monero mnemonic unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.util import msg,msg_r
|
||||
|
||||
from ..include.common import cfg,qmsg,vmsg
|
||||
|
||||
class unit_test(object):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue