From 5f3920b11a39e5a1bd76af6a1d7fc4afe0469f99 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 18 Oct 2024 10:32:15 +0000 Subject: [PATCH] unit_tests.py -> modtest.py, daemontest.py --- .github/workflows/pylint.yaml | 2 +- mmgen/cfg.py | 2 +- mmgen/data/version | 2 +- test/daemontest.py | 10 +++++ .../ut_daemon.py => daemontest_d/ut_exec.py} | 4 +- test/{unit_tests_d => daemontest_d}/ut_msg.py | 2 +- test/{unit_tests_d => daemontest_d}/ut_rpc.py | 2 +- .../ut_tx.py} | 19 +++++++++- test/{unit_tests.py => include/unit_test.py} | 38 ++++++++++--------- test/modtest.py | 10 +++++ test/{unit_tests_d => modtest_d}/__init__.py | 2 +- .../ut_addrlist.py | 2 +- .../ut_addrparse.py | 2 +- .../ut_baseconv.py | 2 +- test/{unit_tests_d => modtest_d}/ut_bip39.py | 2 +- test/{unit_tests_d => modtest_d}/ut_bip_hd.py | 10 +---- .../ut_cashaddr.py | 2 +- test/{unit_tests_d => modtest_d}/ut_dep.py | 2 +- .../ut_devtools.py | 2 +- test/{unit_tests_d => modtest_d}/ut_ecc.py | 2 +- test/{unit_tests_d => modtest_d}/ut_flags.py | 2 +- test/{unit_tests_d => modtest_d}/ut_gen.py | 2 +- .../ut_indexed_dict.py | 2 +- .../ut_lockable.py | 2 +- test/{unit_tests_d => modtest_d}/ut_misc.py | 2 +- .../ut_mn_entry.py | 2 +- test/{unit_tests_d => modtest_d}/ut_obj.py | 2 +- test/{unit_tests_d => modtest_d}/ut_scrypt.py | 2 +- .../ut_seedsplit.py | 2 +- .../{unit_tests_d => modtest_d}/ut_subseed.py | 2 +- .../{unit_tests_d => modtest_d}/ut_testdep.py | 2 +- test/{unit_tests_d => modtest_d}/ut_tx.py | 18 +-------- test/{unit_tests_d => modtest_d}/ut_util.py | 2 +- .../{unit_tests_d => modtest_d}/ut_xmrseed.py | 2 +- test/test-release.d/cfg.sh | 20 ++++++---- test/test-release.sh | 19 ++++++---- test/tooltest2_d/data.py | 6 +-- 37 files changed, 118 insertions(+), 90 deletions(-) create mode 100755 test/daemontest.py rename test/{unit_tests_d/ut_daemon.py => daemontest_d/ut_exec.py} (97%) rename test/{unit_tests_d => daemontest_d}/ut_msg.py (98%) rename test/{unit_tests_d => daemontest_d}/ut_rpc.py (99%) rename test/{unit_tests_d/ut_tx_deserialize.py => daemontest_d/ut_tx.py} (91%) rename test/{unit_tests.py => include/unit_test.py} (86%) create mode 100755 test/modtest.py rename test/{unit_tests_d => modtest_d}/__init__.py (86%) rename test/{unit_tests_d => modtest_d}/ut_addrlist.py (97%) rename test/{unit_tests_d => modtest_d}/ut_addrparse.py (97%) rename test/{unit_tests_d => modtest_d}/ut_baseconv.py (99%) rename test/{unit_tests_d => modtest_d}/ut_bip39.py (99%) rename test/{unit_tests_d => modtest_d}/ut_bip_hd.py (97%) rename test/{unit_tests_d => modtest_d}/ut_cashaddr.py (98%) rename test/{unit_tests_d => modtest_d}/ut_dep.py (98%) rename test/{unit_tests_d => modtest_d}/ut_devtools.py (97%) rename test/{unit_tests_d => modtest_d}/ut_ecc.py (97%) rename test/{unit_tests_d => modtest_d}/ut_flags.py (96%) rename test/{unit_tests_d => modtest_d}/ut_gen.py (97%) rename test/{unit_tests_d => modtest_d}/ut_indexed_dict.py (94%) rename test/{unit_tests_d => modtest_d}/ut_lockable.py (98%) rename test/{unit_tests_d => modtest_d}/ut_misc.py (98%) rename test/{unit_tests_d => modtest_d}/ut_mn_entry.py (96%) rename test/{unit_tests_d => modtest_d}/ut_obj.py (98%) rename test/{unit_tests_d => modtest_d}/ut_scrypt.py (97%) rename test/{unit_tests_d => modtest_d}/ut_seedsplit.py (98%) rename test/{unit_tests_d => modtest_d}/ut_subseed.py (98%) rename test/{unit_tests_d => modtest_d}/ut_testdep.py (97%) rename test/{unit_tests_d => modtest_d}/ut_tx.py (87%) rename test/{unit_tests_d => modtest_d}/ut_util.py (98%) rename test/{unit_tests_d => modtest_d}/ut_xmrseed.py (98%) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index 8a5c6296..1c441e01 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -58,4 +58,4 @@ jobs: pylint --errors-only --jobs=0 mmgen pylint --errors-only --jobs=0 test pylint --errors-only --jobs=0 examples - pylint --errors-only --jobs=0 --disable=relative-beyond-top-level test/cmdtest_py_d + pylint --errors-only --jobs=0 --disable=relative-beyond-top-level test/cmdtest_d diff --git a/mmgen/cfg.py b/mmgen/cfg.py index abffb64d..3fe5bb51 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -400,7 +400,7 @@ class Config(Lockable): short_disp_timeout = 0.1 if os.getenv('MMGEN_TEST_SUITE_POPEN_SPAWN'): stdin_tty = True - if gc.prog_name == 'unit_tests.py': + if gc.prog_name == 'modtest.py': _set_ok += ('debug_subseed',) _reset_ok += ('force_standalone_scrypt_module',) diff --git a/mmgen/data/version b/mmgen/data/version index 4e053177..f08075ae 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -15.1.dev5 +15.1.dev6 diff --git a/test/daemontest.py b/test/daemontest.py new file mode 100755 index 00000000..4c4c3b3c --- /dev/null +++ b/test/daemontest.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +""" +test/daemontest.py: Daemon-related unit tests for the MMGen suite +""" + +try: + from include import unit_test +except ImportError: + from test.include import unit_test diff --git a/test/unit_tests_d/ut_daemon.py b/test/daemontest_d/ut_exec.py similarity index 97% rename from test/unit_tests_d/ut_daemon.py rename to test/daemontest_d/ut_exec.py index 4d468fb5..85acac1c 100755 --- a/test/unit_tests_d/ut_daemon.py +++ b/test/daemontest_d/ut_exec.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_daemon: unit test for the MMGen suite's Daemon class +test.daemontest_d.ut_exec: unit test for the MMGen suite's Daemon class """ from subprocess import run, PIPE @@ -91,7 +91,7 @@ class unit_tests: return True - def exec(self, name, ut): + def avail(self, name, ut): return self._test_cmd(['start', '-Vm'], 'Testing availability of coin daemons...') def cmds(self, name, ut): diff --git a/test/unit_tests_d/ut_msg.py b/test/daemontest_d/ut_msg.py similarity index 98% rename from test/unit_tests_d/ut_msg.py rename to test/daemontest_d/ut_msg.py index 1208b0d8..cf91dec4 100755 --- a/test/unit_tests_d/ut_msg.py +++ b/test/daemontest_d/ut_msg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_msg: message signing unit tests for the MMGen suite +test.daemontest_d.ut_msg: message signing unit tests for the MMGen suite """ import os diff --git a/test/unit_tests_d/ut_rpc.py b/test/daemontest_d/ut_rpc.py similarity index 99% rename from test/unit_tests_d/ut_rpc.py rename to test/daemontest_d/ut_rpc.py index 68e11712..c2d434f0 100755 --- a/test/unit_tests_d/ut_rpc.py +++ b/test/daemontest_d/ut_rpc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_rpc: RPC unit test for the MMGen suite +test.daemontest_d.ut_rpc: RPC unit test for the MMGen suite """ import sys, os diff --git a/test/unit_tests_d/ut_tx_deserialize.py b/test/daemontest_d/ut_tx.py similarity index 91% rename from test/unit_tests_d/ut_tx_deserialize.py rename to test/daemontest_d/ut_tx.py index b5011b30..bb0efe64 100755 --- a/test/unit_tests_d/ut_tx_deserialize.py +++ b/test/daemontest_d/ut_tx.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_tx_deserialize: TX deserialization unit tests for the MMGen suite +test.daemontest_d.ut_tx: TX daemon tests for the MMGen suite """ import os, json @@ -13,8 +13,10 @@ 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 mmgen.tx import NewTX -from ..include.common import cfg, start_test_daemons, stop_test_daemons +from ..include.common import cfg, start_test_daemons, stop_test_daemons, qmsg def print_info(name, extra_desc): if cfg.names: @@ -106,6 +108,19 @@ class unit_tests: altcoin_deps = ('mmgen_ref_alt',) + async def newtx(self, name, ut): + qmsg(' Testing NewTX initializer') + d = CoinDaemon(cfg, 'btc', test_suite=True) + d.start() + + proto = init_proto(cfg, 'btc', need_amt=True) + await NewTX(cfg=cfg, proto=proto) + + d.stop() + d.remove_datadir() + qmsg(' OK') + return True + async def core_vectors(self, name, ut): core_repo_root = os.getenv('CORE_REPO_ROOT') diff --git a/test/unit_tests.py b/test/include/unit_test.py similarity index 86% rename from test/unit_tests.py rename to test/include/unit_test.py index b7b366e1..0d9162bd 100755 --- a/test/unit_tests.py +++ b/test/include/unit_test.py @@ -17,15 +17,12 @@ # along with this program. If not, see . """ -test/unit_tests.py: Unit tests for the MMGen suite +test.include.unit_test: Unit test framework for the MMGen suite """ import sys, os, time, importlib, platform, asyncio -try: - from include.test_init import repo_root -except ImportError: - from test.include.test_init import repo_root +from .test_init import repo_root # for the unit tests, violate MMGen Project best practices and allow use of the dev tools # in production code: @@ -82,9 +79,16 @@ set_globals(cfg) file_pfx = 'ut_' -tests_d = os.path.join(repo_root, 'test', 'unit_tests_d') +test_type = { + 'modtest.py': 'unit', + 'daemontest.py': 'daemon', +}[gc.prog_name] -all_tests = sorted(fn[len(file_pfx):-len('.py')] for fn in os.listdir(tests_d) if fn.startswith(file_pfx)) +test_subdir = gc.prog_name.removesuffix('.py') + '_d' + +test_dir = os.path.join(repo_root, 'test', test_subdir) + +all_tests = sorted(fn[len(file_pfx):-len('.py')] for fn in os.listdir(test_dir) if fn.startswith(file_pfx)) exclude = cfg.exclude.split(',') if cfg.exclude else [] @@ -101,7 +105,7 @@ if cfg.list: if cfg.list_subtests: def gen(): for test in all_tests: - mod = importlib.import_module(f'test.unit_tests_d.{file_pfx}{test}') + mod = importlib.import_module(f'test.{test_subdir}.{file_pfx}{test}') if hasattr(mod, 'unit_tests'): t = getattr(mod, 'unit_tests') subtests = [k for k, v in t.__dict__.items() if type(v).__name__ == 'function' and k[0] != '_'] @@ -148,11 +152,11 @@ class UnitTestHelpers: tests_seen = [] def run_test(test, subtest=None): - mod = importlib.import_module(f'test.unit_tests_d.{file_pfx}{test}') + mod = importlib.import_module(f'test.{test_subdir}.{file_pfx}{test}') def run_subtest(t, subtest): subtest_disp = subtest.replace('_', '-') - msg(brown('Running unit subtest ') + orange(f'{test}.{subtest_disp}')) + msg(brown(f'Running {test_type} subtest ') + orange(f'{test}.{subtest_disp}')) if getattr(t, 'silence_output', False): t._silence() @@ -190,11 +194,11 @@ def run_test(test, subtest=None): die(4, f'Unit subtest {subtest_disp!r} failed') if test not in tests_seen: - gmsg(f'Running unit test {test}') + gmsg(f'Running {test_type} test {test}') tests_seen.append(test) if cfg.no_altcoin_deps and getattr(mod, 'altcoin_dep', None): - cfg._util.qmsg(gray(f'Skipping unit test {test!r} [--no-altcoin-deps]')) + cfg._util.qmsg(gray(f'Skipping {test_type} test {test!r} [--no-altcoin-deps]')) return if hasattr(mod, 'unit_tests'): # new class-based API @@ -212,22 +216,22 @@ def run_test(test, subtest=None): for _subtest in subtests: subtest_disp = _subtest.replace('_', '-') if cfg.no_altcoin_deps and _subtest in altcoin_deps: - cfg._util.qmsg(gray(f'Skipping unit subtest {subtest_disp!r} [--no-altcoin-deps]')) + cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} [--no-altcoin-deps]')) continue if sys.platform == 'win32' and _subtest in win_skip: - cfg._util.qmsg(gray(f'Skipping unit subtest {subtest_disp!r} for Windows platform')) + cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for Windows platform')) continue if sys.platform == 'darwin' and _subtest in mac_skip: - cfg._util.qmsg(gray(f'Skipping unit subtest {subtest_disp!r} for macOS platform')) + cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for macOS platform')) continue if platform.machine() == 'aarch64' and _subtest in arm_skip: - cfg._util.qmsg(gray(f'Skipping unit subtest {subtest_disp!r} for ARM platform')) + cfg._util.qmsg(gray(f'Skipping {test_type} subtest {subtest_disp!r} for ARM platform')) continue run_subtest(t, _subtest) if hasattr(t, '_post'): t._post() else: - assert not subtest, f'{subtest!r}: subtests not supported for this unit test' + assert not subtest, f'{subtest!r}: subtests not supported for this {test_type} test' if not mod.unit_test().run_test(test, UnitTestHelpers(test)): die(4, 'Unit test {test!r} failed') diff --git a/test/modtest.py b/test/modtest.py new file mode 100755 index 00000000..d21bd4e2 --- /dev/null +++ b/test/modtest.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +""" +test/modtest.py: Unit tests for the MMGen suite +""" + +try: + from include import unit_test +except ImportError: + from test.include import unit_test diff --git a/test/unit_tests_d/__init__.py b/test/modtest_d/__init__.py similarity index 86% rename from test/unit_tests_d/__init__.py rename to test/modtest_d/__init__.py index 9130bdb5..cdeaac5d 100755 --- a/test/unit_tests_d/__init__.py +++ b/test/modtest_d/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.__init__: shared data for unit tests for the MMGen suite +test.modtest_d.__init__: shared data for unit tests for the MMGen suite """ import sys, os diff --git a/test/unit_tests_d/ut_addrlist.py b/test/modtest_d/ut_addrlist.py similarity index 97% rename from test/unit_tests_d/ut_addrlist.py rename to test/modtest_d/ut_addrlist.py index ff8d3ca2..155d26f4 100755 --- a/test/unit_tests_d/ut_addrlist.py +++ b/test/modtest_d/ut_addrlist.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_addrlist: address list unit tests for the MMGen suite +test.modtest_d.ut_addrlist: address list unit tests for the MMGen suite """ from mmgen.color import blue diff --git a/test/unit_tests_d/ut_addrparse.py b/test/modtest_d/ut_addrparse.py similarity index 97% rename from test/unit_tests_d/ut_addrparse.py rename to test/modtest_d/ut_addrparse.py index fed0dee1..13eaea93 100755 --- a/test/unit_tests_d/ut_addrparse.py +++ b/test/modtest_d/ut_addrparse.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_addrparse: address parsing tests for the MMGen suite +test.modtest_d.ut_addrparse: address parsing tests for the MMGen suite """ from mmgen.color import yellow, cyan diff --git a/test/unit_tests_d/ut_baseconv.py b/test/modtest_d/ut_baseconv.py similarity index 99% rename from test/unit_tests_d/ut_baseconv.py rename to test/modtest_d/ut_baseconv.py index 743b8f27..8f867f7b 100755 --- a/test/unit_tests_d/ut_baseconv.py +++ b/test/modtest_d/ut_baseconv.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_baseconv: Base conversion unit test for the MMGen suite +test.modtest_d.ut_baseconv: Base conversion unit test for the MMGen suite """ from mmgen.util import msg, msg_r diff --git a/test/unit_tests_d/ut_bip39.py b/test/modtest_d/ut_bip39.py similarity index 99% rename from test/unit_tests_d/ut_bip39.py rename to test/modtest_d/ut_bip39.py index 8573ba37..08dcae62 100755 --- a/test/unit_tests_d/ut_bip39.py +++ b/test/modtest_d/ut_bip39.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_bip39: BIP39 unit test for the MMGen suite +test.modtest_d.ut_bip39: BIP39 unit test for the MMGen suite """ from mmgen.color import blue, orange, purple diff --git a/test/unit_tests_d/ut_bip_hd.py b/test/modtest_d/ut_bip_hd.py similarity index 97% rename from test/unit_tests_d/ut_bip_hd.py rename to test/modtest_d/ut_bip_hd.py index c8abd7db..4a6c7631 100755 --- a/test/unit_tests_d/ut_bip_hd.py +++ b/test/modtest_d/ut_bip_hd.py @@ -1,15 +1,7 @@ #!/usr/bin/env python3 -# -# MMGen Wallet, a terminal-based cryptocurrency wallet -# Copyright (C)2013-2024 The MMGen Project -# 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.unit_tests_d.ut_bip_hd: bip_hd unit test for the MMGen suite +test.modtest_d.ut_bip_hd: bip_hd unit test for the MMGen suite """ from mmgen.color import gray, pink, blue diff --git a/test/unit_tests_d/ut_cashaddr.py b/test/modtest_d/ut_cashaddr.py similarity index 98% rename from test/unit_tests_d/ut_cashaddr.py rename to test/modtest_d/ut_cashaddr.py index b4213376..cd0c146d 100755 --- a/test/unit_tests_d/ut_cashaddr.py +++ b/test/modtest_d/ut_cashaddr.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_cashaddr: unit test for the BCH cashaddr module +test.modtest_d.ut_cashaddr: unit test for the BCH cashaddr module """ altcoin_dep = True diff --git a/test/unit_tests_d/ut_dep.py b/test/modtest_d/ut_dep.py similarity index 98% rename from test/unit_tests_d/ut_dep.py rename to test/modtest_d/ut_dep.py index 2671070b..04cea944 100755 --- a/test/unit_tests_d/ut_dep.py +++ b/test/modtest_d/ut_dep.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite +test.modtest_d.ut_dep: dependency unit tests for the MMGen suite Test whether dependencies are installed and functional. No data verification is performed. diff --git a/test/unit_tests_d/ut_devtools.py b/test/modtest_d/ut_devtools.py similarity index 97% rename from test/unit_tests_d/ut_devtools.py rename to test/modtest_d/ut_devtools.py index 35d2482a..aad9fdaa 100755 --- a/test/unit_tests_d/ut_devtools.py +++ b/test/modtest_d/ut_devtools.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_devtools: devtools unit tests for the MMGen suite +test.modtest_d.ut_devtools: devtools unit tests for the MMGen suite """ import os, json diff --git a/test/unit_tests_d/ut_ecc.py b/test/modtest_d/ut_ecc.py similarity index 97% rename from test/unit_tests_d/ut_ecc.py rename to test/modtest_d/ut_ecc.py index 67c3831d..4587516b 100755 --- a/test/unit_tests_d/ut_ecc.py +++ b/test/modtest_d/ut_ecc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_ecc: elliptic curve unit test for the MMGen suite +test.modtest_d.ut_ecc: elliptic curve unit test for the MMGen suite """ from mmgen.proto.secp256k1.secp256k1 import pubkey_gen, pubkey_tweak_add, pubkey_check diff --git a/test/unit_tests_d/ut_flags.py b/test/modtest_d/ut_flags.py similarity index 96% rename from test/unit_tests_d/ut_flags.py rename to test/modtest_d/ut_flags.py index 4569bc00..8d9eb342 100755 --- a/test/unit_tests_d/ut_flags.py +++ b/test/modtest_d/ut_flags.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_flags: unit test for the MMGen suite's ClassFlags class +test.modtest_d.ut_flags: unit test for the MMGen suite's ClassFlags class """ from mmgen.flags import ClassOpts, ClassFlags diff --git a/test/unit_tests_d/ut_gen.py b/test/modtest_d/ut_gen.py similarity index 97% rename from test/unit_tests_d/ut_gen.py rename to test/modtest_d/ut_gen.py index 44ead243..f6514029 100755 --- a/test/unit_tests_d/ut_gen.py +++ b/test/modtest_d/ut_gen.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_gen: key/address generation unit tests for the MMGen suite +test.modtest_d.ut_gen: key/address generation unit tests for the MMGen suite """ from mmgen.color import blue diff --git a/test/unit_tests_d/ut_indexed_dict.py b/test/modtest_d/ut_indexed_dict.py similarity index 94% rename from test/unit_tests_d/ut_indexed_dict.py rename to test/modtest_d/ut_indexed_dict.py index eb80e860..02d6be2b 100755 --- a/test/unit_tests_d/ut_indexed_dict.py +++ b/test/modtest_d/ut_indexed_dict.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_indexed_dict: IndexedDict class unit test for the MMGen suite +test.modtest_d.ut_indexed_dict: IndexedDict class unit test for the MMGen suite """ from mmgen.util import msg, msg_r, die diff --git a/test/unit_tests_d/ut_lockable.py b/test/modtest_d/ut_lockable.py similarity index 98% rename from test/unit_tests_d/ut_lockable.py rename to test/modtest_d/ut_lockable.py index 9b5187f1..41cb2318 100755 --- a/test/unit_tests_d/ut_lockable.py +++ b/test/modtest_d/ut_lockable.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_lockable: unit test for the MMGen suite's Lockable class +test.modtest_d.ut_lockable: unit test for the MMGen suite's Lockable class """ from decimal import Decimal diff --git a/test/unit_tests_d/ut_misc.py b/test/modtest_d/ut_misc.py similarity index 98% rename from test/unit_tests_d/ut_misc.py rename to test/modtest_d/ut_misc.py index 09255c11..f77f2b10 100755 --- a/test/unit_tests_d/ut_misc.py +++ b/test/modtest_d/ut_misc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_misc: miscellaneous unit tests for the MMGen suite +test.modtest_d.ut_misc: miscellaneous unit tests for the MMGen suite """ import re, time diff --git a/test/unit_tests_d/ut_mn_entry.py b/test/modtest_d/ut_mn_entry.py similarity index 96% rename from test/unit_tests_d/ut_mn_entry.py rename to test/modtest_d/ut_mn_entry.py index 79a1cc98..53259c59 100755 --- a/test/unit_tests_d/ut_mn_entry.py +++ b/test/modtest_d/ut_mn_entry.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_mn_entry: Mnemonic user entry unit test for the MMGen suite +test.modtest_d.ut_mn_entry: Mnemonic user entry unit test for the MMGen suite """ from mmgen.mn_entry import mn_entry diff --git a/test/unit_tests_d/ut_obj.py b/test/modtest_d/ut_obj.py similarity index 98% rename from test/unit_tests_d/ut_obj.py rename to test/modtest_d/ut_obj.py index bd2398e4..87f8ad90 100755 --- a/test/unit_tests_d/ut_obj.py +++ b/test/modtest_d/ut_obj.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_obj: data object unit tests for the MMGen suite +test.modtest_d.ut_obj: data object unit tests for the MMGen suite """ from decimal import Decimal, getcontext diff --git a/test/unit_tests_d/ut_scrypt.py b/test/modtest_d/ut_scrypt.py similarity index 97% rename from test/unit_tests_d/ut_scrypt.py rename to test/modtest_d/ut_scrypt.py index c5644733..4588a2d4 100755 --- a/test/unit_tests_d/ut_scrypt.py +++ b/test/modtest_d/ut_scrypt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_scrypt: password hashing unit test for the MMGen suite +test.modtest_d.ut_scrypt: password hashing unit test for the MMGen suite """ from mmgen.util import msg, msg_r diff --git a/test/unit_tests_d/ut_seedsplit.py b/test/modtest_d/ut_seedsplit.py similarity index 98% rename from test/unit_tests_d/ut_seedsplit.py rename to test/modtest_d/ut_seedsplit.py index c0412946..d00b2a65 100755 --- a/test/unit_tests_d/ut_seedsplit.py +++ b/test/modtest_d/ut_seedsplit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_seedsplit: seed splitting unit test for the MMGen suite +test.modtest_d.ut_seedsplit: seed splitting unit test for the MMGen suite """ from mmgen.util import msg, msg_r diff --git a/test/unit_tests_d/ut_subseed.py b/test/modtest_d/ut_subseed.py similarity index 98% rename from test/unit_tests_d/ut_subseed.py rename to test/modtest_d/ut_subseed.py index 6b8e2c95..e42a9552 100755 --- a/test/unit_tests_d/ut_subseed.py +++ b/test/modtest_d/ut_subseed.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_subseed: subseed unit test for the MMGen suite +test.modtest_d.ut_subseed: subseed unit test for the MMGen suite """ from mmgen.util import msg, msg_r diff --git a/test/unit_tests_d/ut_testdep.py b/test/modtest_d/ut_testdep.py similarity index 97% rename from test/unit_tests_d/ut_testdep.py rename to test/modtest_d/ut_testdep.py index 7701b94c..35b4b058 100755 --- a/test/unit_tests_d/ut_testdep.py +++ b/test/modtest_d/ut_testdep.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite +test.modtest_d.ut_testdep: test dependency unit tests for the MMGen suite """ import sys, os diff --git a/test/unit_tests_d/ut_tx.py b/test/modtest_d/ut_tx.py similarity index 87% rename from test/unit_tests_d/ut_tx.py rename to test/modtest_d/ut_tx.py index ecae7870..67953cf8 100755 --- a/test/unit_tests_d/ut_tx.py +++ b/test/modtest_d/ut_tx.py @@ -1,15 +1,14 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_tx: TX unit tests for the MMGen suite +test.modtest_d.ut_tx: TX unit tests for the MMGen suite """ import os, re from mmgen.devtools import get_diff, get_ndiff -from mmgen.tx import NewTX, CompletedTX, UnsignedTX +from mmgen.tx import CompletedTX, UnsignedTX from mmgen.tx.file import MMGenTxFile -from mmgen.daemon import CoinDaemon from mmgen.protocol import init_proto from mmgen.cfg import Config @@ -45,19 +44,6 @@ class unit_tests: altcoin_deps = ('txfile_alt', 'txfile_alt_legacy') - async def tx(self, name, ut): - qmsg(' Testing NewTX initializer') - d = CoinDaemon(cfg, 'btc', test_suite=True) - d.start() - - proto = init_proto(cfg, 'btc', need_amt=True) - await NewTX(cfg=cfg, proto=proto) - - d.stop() - d.remove_datadir() - qmsg(' OK') - return True - async def txfile(self, name, ut): return await do_txfile_test( 'Bitcoin', diff --git a/test/unit_tests_d/ut_util.py b/test/modtest_d/ut_util.py similarity index 98% rename from test/unit_tests_d/ut_util.py rename to test/modtest_d/ut_util.py index 97752b07..f855ce62 100755 --- a/test/unit_tests_d/ut_util.py +++ b/test/modtest_d/ut_util.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_misc: utility unit tests for the MMGen suite +test.modtest_d.ut_misc: utility unit tests for the MMGen suite """ from mmgen.color import cyan diff --git a/test/unit_tests_d/ut_xmrseed.py b/test/modtest_d/ut_xmrseed.py similarity index 98% rename from test/unit_tests_d/ut_xmrseed.py rename to test/modtest_d/ut_xmrseed.py index 589c1391..6daaf82d 100755 --- a/test/unit_tests_d/ut_xmrseed.py +++ b/test/modtest_d/ut_xmrseed.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -test/unit_tests_d/ut_xmrseed: Monero mnemonic unit test for the MMGen suite +test.modtest_d.ut_xmrseed: Monero mnemonic unit test for the MMGen suite """ altcoin_dep = True diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index b8df5d0a..a31ff7c6 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -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 help" +all_tests="dep dev lint obj color daemon mod 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 help autosign btc btc_tn btc_rt altref altgen bch bch_rt ltc ltc_rt eth etc xmr' + dfl_tests='dep alt obj color daemon mod 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 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' + noalt_tests='dep alt obj color daemon mod hash ref tool tool2 gen help autosign btc btc_tn btc_rt' + quick_tests='dep alt obj color daemon mod 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' @@ -61,7 +61,10 @@ init_tests() { t_color='- test/colortest.py' d_dep="system and testing dependencies" - t_dep="- $unit_tests_py testdep dep daemon.exec" + t_dep=" + - $modtest_py testdep dep + - $daemontest_py exec + " d_dev="developer scripts ${YELLOW}(additional dependencies required)$RESET" t_dev=" @@ -82,8 +85,11 @@ init_tests() { if [ "$SKIP_ALT_DEP" ]; then t_lint_skip='b'; else t_lint_skip='a'; fi - d_unit="low-level subsystems" - t_unit="- $unit_tests_py --exclude testdep,dep,daemon" + d_daemon="low-level subsystems involving coin daemons" + t_daemon="- $daemontest_py --exclude exec" + + d_mod="low-level subsystems" + t_mod="- $modtest_py --exclude testdep,dep" d_hash="internal hash function implementations" t_hash=" diff --git a/test/test-release.sh b/test/test-release.sh index 3399a279..8c038c03 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -258,7 +258,8 @@ fi cmdtest_py='test/cmdtest.py -n' objtest_py='test/objtest.py' objattrtest_py='test/objattrtest.py' -unit_tests_py='test/unit_tests.py --names --quiet' +modtest_py='test/modtest.py --names --quiet' +daemontest_py='test/daemontest.py --names --quiet' tooltest_py='test/tooltest.py' tooltest2_py='test/tooltest2.py --names --quiet' gentest_py='test/gentest.py --quiet' @@ -312,7 +313,8 @@ do exit ;; A) SKIP_ALT_DEP=1 cmdtest_py+=" --no-altcoin" - unit_tests_py+=" --no-altcoin-deps" + modtest_py+=" --no-altcoin-deps" + daemontest_py+=" --no-altcoin-deps" scrambletest_py+=" --no-altcoin" tooltest2_py+=" --no-altcoin" ;; b) cmdtest_py+=" --buf-keypress" ;; @@ -323,7 +325,8 @@ do tooltest2_py+=" --fork --coverage" scrambletest_py+=" --coverage" python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace" - unit_tests_py="$python $unit_tests_py" + modtest_py="$python $modtest_py" + daemontest_py="$python $daemontest_py" objtest_py="$python $objtest_py" objattrtest_py="$python $objattrtest_py" gentest_py="$python $gentest_py" @@ -334,8 +337,8 @@ do D) export MMGEN_TEST_SUITE_DETERMINISTIC=1 export MMGEN_DISABLE_COLOR=1 ;; e) exec_prog=$(realpath $OPTARG) ;; - f) rounds=6 FAST=1 fast_opt='--fast' unit_tests_py+=" --fast" ;; - F) rounds=3 FAST=1 fast_opt='--fast' unit_tests_py+=" --fast" ;; + f) rounds=6 FAST=1 fast_opt='--fast' modtest_py+=" --fast" daemontest_py+=" --fast" ;; + F) rounds=3 FAST=1 fast_opt='--fast' modtest_py+=" --fast" daemontest_py+=" --fast" ;; I) INSTALL_PACKAGE=1 ;; L) list_avail_tests; exit ;; l) list_group_symbols; exit ;; @@ -350,7 +353,8 @@ do V) VERBOSE='--verbose' VERBOSE_SHORTOPT='-v' QUIET='' [ "$EXACT_OUTPUT" ] || cmdtest_py+=" --verbose" STDOUT_DEVNULL='' STDERR_DEVNULL='' - unit_tests_py="${unit_tests_py/--quiet/--verbose}" + modtest_py="${modtest_py/--quiet/--verbose}" + daemontest_py="${daemontest_py/--quiet/--verbose}" altcoin_mod_opts="${altcoin_mod_opts/--quiet/--verbose}" tooltest2_py="${tooltest2_py/--quiet/--verbose}" gentest_py="${gentest_py/--quiet/--verbose}" @@ -387,7 +391,8 @@ case $1 in 'noalt') tests=$noalt_tests SKIP_ALT_DEP=1 cmdtest_py+=" --no-altcoin" - unit_tests_py+=" --no-altcoin-deps" + modtest_py+=" --no-altcoin-deps" + daemontest_py+=" --no-altcoin-deps" scrambletest_py+=" --no-altcoin" ;; 'quick') tests=$quick_tests ;; 'qskip') tests=$qskip_tests ;; diff --git a/test/tooltest2_d/data.py b/test/tooltest2_d/data.py index 10762d34..ec1bbc97 100755 --- a/test/tooltest2_d/data.py +++ b/test/tooltest2_d/data.py @@ -23,9 +23,9 @@ from mmgen.bip39 import is_bip39_mnemonic from mmgen.baseconv import is_mmgen_mnemonic, is_b58_str from mmgen.xmrseed import is_xmrseed -from ..unit_tests_d.ut_baseconv import unit_test as ut_baseconv -from ..unit_tests_d.ut_bip39 import unit_tests as ut_bip39 -from ..unit_tests_d.ut_xmrseed import unit_tests as ut_xmrseed +from ..modtest_d.ut_baseconv import unit_test as ut_baseconv +from ..modtest_d.ut_bip39 import unit_tests as ut_bip39 +from ..modtest_d.ut_xmrseed import unit_tests as ut_xmrseed from ..include.common import cfg, sample_text proto = cfg._proto