From aff850d1c8c033624801018a1aae90dad80a9fd3 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 3 Oct 2023 14:27:57 +0000 Subject: [PATCH] test suite: import cleanups --- mmgen/main_split.py | 4 +++- test/colortest.py | 1 + test/include/coin_daemon_control.py | 3 ++- test/include/common.py | 7 +++++-- test/misc/cfg.py | 5 ++++- test/misc/get_passphrase.py | 8 +++++--- test/misc/input_func.py | 3 ++- test/misc/oneshot_warning.py | 3 ++- test/misc/opts.py | 3 ++- test/misc/term.py | 4 +++- test/test.py | 4 ++-- test/test_py_d/common.py | 5 ++++- test/test_py_d/ts_autosign.py | 2 ++ test/test_py_d/ts_cfgfile.py | 4 +++- test/test_py_d/ts_ethdev.py | 1 + test/test_py_d/ts_input.py | 2 ++ test/test_py_d/ts_main.py | 3 +++ test/test_py_d/ts_misc.py | 2 ++ test/test_py_d/ts_ref.py | 1 + test/test_py_d/ts_ref_3seed.py | 1 + test/test_py_d/ts_ref_altcoin.py | 3 +++ test/test_py_d/ts_regtest.py | 4 ++-- test/test_py_d/ts_seedsplit.py | 1 + test/test_py_d/ts_shared.py | 2 +- test/test_py_d/ts_tool.py | 3 +++ test/test_py_d/ts_wallet.py | 1 + test/tooltest2.py | 6 +++++- test/unit_tests_d/ut_tx_deserialize.py | 1 + 28 files changed, 67 insertions(+), 20 deletions(-) diff --git a/mmgen/main_split.py b/mmgen/main_split.py index 0b59c44f..7394effa 100755 --- a/mmgen/main_split.py +++ b/mmgen/main_split.py @@ -25,7 +25,8 @@ mmgen-split: Split funds after a replayable chain fork using a timelocked transa import time -from .common import * +from .cfg import Config +from .util import gmsg,die opts_data = { 'text': { @@ -125,6 +126,7 @@ async def main(): gmsg(f'Creating timelocked transaction for long chain ({proto.coin})') locktime = int(cfg.locktime) if not locktime: + from .rpc import rpc_init rpc = rpc_init(proto) locktime = rpc.call('getblockcount') tx1.create(mmids[0],locktime) diff --git a/test/colortest.py b/test/colortest.py index dc78fd5f..5f250b6a 100755 --- a/test/colortest.py +++ b/test/colortest.py @@ -10,6 +10,7 @@ test/colortest.py: test color handling for the MMGen suite import include.test_init from include.common import * from mmgen.color import * +from mmgen.util import msg,ymsg,gmsg import mmgen.color as color_mod def test_color(): diff --git a/test/include/coin_daemon_control.py b/test/include/coin_daemon_control.py index 1e431245..94ce2c35 100755 --- a/test/include/coin_daemon_control.py +++ b/test/include/coin_daemon_control.py @@ -13,7 +13,8 @@ test.include.coin_daemon_control: Start and stop daemons for the MMGen test suit """ import include.test_init -from mmgen.common import * +from mmgen.cfg import Config,gc +from mmgen.util import msg,die,oneshot_warning,async_run from mmgen.protocol import init_proto xmr_wallet_network_ids = { diff --git a/test/include/common.py b/test/include/common.py index c57e0ace..6e7dbe1f 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -20,9 +20,12 @@ test.include.common: Shared routines and data for the MMGen test suites """ -import os +import sys,os from subprocess import run,PIPE -from mmgen.common import * + +from mmgen.cfg import gv +from mmgen.color import yellow,green,orange +from mmgen.util import msg,msg_r,Msg,Msg_r,gmsg,die from mmgen.fileutil import write_data_to_file,get_data_from_file def noop(*args,**kwargs): diff --git a/test/misc/cfg.py b/test/misc/cfg.py index 9cb0f524..2ca0f87c 100755 --- a/test/misc/cfg.py +++ b/test/misc/cfg.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 -from mmgen.common import * +import os + +from mmgen.cfg import Config +from mmgen.util import msg cfg = Config(process_opts=True) diff --git a/test/misc/get_passphrase.py b/test/misc/get_passphrase.py index d01adda6..aac60ecc 100755 --- a/test/misc/get_passphrase.py +++ b/test/misc/get_passphrase.py @@ -5,7 +5,8 @@ pn = os.path.abspath(os.path.dirname(sys.argv[0])) os.chdir(os.path.dirname(os.path.dirname(pn))) sys.path[0] = os.curdir -from mmgen.common import * +from mmgen.cfg import Config,gc +from mmgen.util import msg opts_data = { 'text': { @@ -43,6 +44,9 @@ def crypto(): msg(f'==> got hash preset: [{hp}]') def seed(): + + from mmgen.wallet import Wallet + for n in range(1,3): msg(f'------- NEW WALLET {n} -------\n') w1 = Wallet(cfg) @@ -57,6 +61,4 @@ def seed(): w3 = Wallet(cfg,fn='test/ref/FE3C6545-D782B529[128,1].mmdat') # passphrase: 'reference password' msg(f'\n==> got pw,preset,lbl: [{w3.ssdata.passwd}][{w3.ssdata.hash_preset}][{w3.ssdata.label}]\n') -from mmgen.wallet import Wallet - globals()[cfg._args[0]]() diff --git a/test/misc/input_func.py b/test/misc/input_func.py index 7acb4e16..cc0b0393 100755 --- a/test/misc/input_func.py +++ b/test/misc/input_func.py @@ -5,7 +5,8 @@ import sys,os os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0]))))) sys.path[0] = os.curdir -from mmgen.common import * +from mmgen.cfg import Config +from mmgen.util import msg opts_data = { 'text': { diff --git a/test/misc/oneshot_warning.py b/test/misc/oneshot_warning.py index 62b26e91..932f3b2e 100755 --- a/test/misc/oneshot_warning.py +++ b/test/misc/oneshot_warning.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -from mmgen.common import * +from mmgen.cfg import Config +from mmgen.util import msg,oneshot_warning,oneshot_warning_group cfg = Config() diff --git a/test/misc/opts.py b/test/misc/opts.py index 36c56fdc..606761e4 100755 --- a/test/misc/opts.py +++ b/test/misc/opts.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -from mmgen.common import * +from mmgen.cfg import Config +from mmgen.util import msg opts_data = { 'sets': [('print_checksum',True,'quiet',True)], diff --git a/test/misc/term.py b/test/misc/term.py index 3b80c269..e21f5500 100755 --- a/test/misc/term.py +++ b/test/misc/term.py @@ -6,7 +6,9 @@ parpar = os.path.dirname(os.path.dirname(pn)) os.chdir(parpar) sys.path[0] = os.curdir -from mmgen.common import * +from mmgen.cfg import Config,gc +from mmgen.color import yellow,blue,cyan,set_vt100 +from mmgen.util import msg,ymsg,gmsg,fmt,fmt_list,die commands = [ 'start', diff --git a/test/test.py b/test/test.py index 8060bfec..5d1d562e 100755 --- a/test/test.py +++ b/test/test.py @@ -89,8 +89,8 @@ else: repo_root = include.test_init.repo_root from mmgen.cfg import Config,gc -from mmgen.color import yellow,green,cyan -from mmgen.util import Msg,bmsg,die,suf,make_timestr +from mmgen.color import red,yellow,green,blue,cyan,nocolor +from mmgen.util import Msg,bmsg,die,suf,make_timestr,async_run from test.include.common import ( set_globals, diff --git a/test/test_py_d/common.py b/test/test_py_d/common.py index e8f2fb7d..6d348750 100755 --- a/test/test_py_d/common.py +++ b/test/test_py_d/common.py @@ -21,9 +21,12 @@ test.test_py_d.common: Shared routines and data for the test.py test suite """ import sys,os + from mmgen.cfg import gc +from mmgen.color import green from mmgen.util import msg -from ..include.common import * + +from ..include.common import cfg,getrand,text_jp,text_zh,ascii_cyr_gr,lat_cyr_gr rt_pw = 'abc-α' ref_wallet_brainpass = 'abc' diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index 7002cea6..05434af2 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -25,6 +25,8 @@ from subprocess import run from pathlib import Path from mmgen.cfg import gc +from mmgen.color import red,green,blue,purple +from mmgen.util import suf from ..include.common import * from .common import * diff --git a/test/test_py_d/ts_cfgfile.py b/test/test_py_d/ts_cfgfile.py index 8000c0bc..75cac871 100755 --- a/test/test_py_d/ts_cfgfile.py +++ b/test/test_py_d/ts_cfgfile.py @@ -10,11 +10,13 @@ test.test_py_d.ts_cfgfile: CfgFile tests for the MMGen test.py test suite """ -import shutil +import time,shutil from ..include.common import * from .ts_base import * + from mmgen.cfgfile import * +from mmgen.color import yellow class TestSuiteCfgFile(TestSuiteBase): 'CfgFile API' diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index c7399fec..1522ad0f 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -26,6 +26,7 @@ from collections import namedtuple from subprocess import run,PIPE,DEVNULL from mmgen.cfg import gc +from mmgen.color import yellow,blue,cyan,set_vt100 from mmgen.util import die from mmgen.protocol import CoinProtocol from ..include.common import * diff --git a/test/test_py_d/ts_input.py b/test/test_py_d/ts_input.py index 2dead78b..f2fa1eb0 100755 --- a/test/test_py_d/ts_input.py +++ b/test/test_py_d/ts_input.py @@ -15,6 +15,8 @@ import time from ..include.common import * from .ts_base import * from .input import * + +from mmgen.util import capfirst,remove_whitespace from mmgen.wallet import get_wallet_cls class TestSuiteInput(TestSuiteBase): diff --git a/test/test_py_d/ts_main.py b/test/test_py_d/ts_main.py index 4e247436..8e34846a 100755 --- a/test/test_py_d/ts_main.py +++ b/test/test_py_d/ts_main.py @@ -20,6 +20,9 @@ test.test_py_d.ts_main: Basic operations tests for the test.py test suite """ +from mmgen.util import async_run,capfirst,get_extension +from mmgen.color import green,cyan + from mmgen.fileutil import get_data_from_file,write_data_to_file from mmgen.wallet import get_wallet_cls from mmgen.wallet.mmgen import wallet as MMGenWallet diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index fba409c2..a22328e0 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -20,6 +20,8 @@ test.test_py_d.ts_misc: Miscellaneous test groups for the test.py test suite """ +import re,time + from mmgen.cfg import gc from ..include.common import * from .common import * diff --git a/test/test_py_d/ts_ref.py b/test/test_py_d/ts_ref.py index 0f95f7ef..926deb30 100755 --- a/test/test_py_d/ts_ref.py +++ b/test/test_py_d/ts_ref.py @@ -21,6 +21,7 @@ test.test_py_d.ts_ref: Reference file tests for the test.py test suite """ import os +from mmgen.util import capfirst from mmgen.wallet import get_wallet_cls from ..include.common import * from .common import * diff --git a/test/test_py_d/ts_ref_3seed.py b/test/test_py_d/ts_ref_3seed.py index 13d69f23..821e0a1d 100755 --- a/test/test_py_d/ts_ref_3seed.py +++ b/test/test_py_d/ts_ref_3seed.py @@ -21,6 +21,7 @@ test.test_py_d.ts_ref_3seed: Saved and generated reference file tests for 128, 192 and 256-bit seeds for the test.py test suite """ +from mmgen.util import capfirst from mmgen.wallet import get_wallet_cls from ..include.common import * from .common import * diff --git a/test/test_py_d/ts_ref_altcoin.py b/test/test_py_d/ts_ref_altcoin.py index b1bdaf93..0e763ee2 100755 --- a/test/test_py_d/ts_ref_altcoin.py +++ b/test/test_py_d/ts_ref_altcoin.py @@ -21,6 +21,9 @@ test.test_py_d.ts_ref_altcoin: Altcoin reference file tests for the test.py test """ import os + +from mmgen.color import set_vt100 + from .common import * from ..include.common import cfg from .ts_ref import * diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index de74ed68..b7e07702 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -20,9 +20,9 @@ test.test_py_d.ts_regtest: Regtest tests for the test.py test suite """ -import os,json,time +import os,json,time,re from decimal import Decimal -from mmgen.util import die,gmsg +from mmgen.util import die,gmsg,capfirst,fmt_list,async_run from mmgen.protocol import init_proto from mmgen.addrlist import AddrList from mmgen.wallet import Wallet,get_wallet_cls diff --git a/test/test_py_d/ts_seedsplit.py b/test/test_py_d/ts_seedsplit.py index fcafdf7f..2a998a3b 100755 --- a/test/test_py_d/ts_seedsplit.py +++ b/test/test_py_d/ts_seedsplit.py @@ -21,6 +21,7 @@ test.test_py_d.ts_seedsplit: Seed split/join tests for the test.py test suite """ from mmgen.wallet import get_wallet_cls +from mmgen.util import capfirst from .ts_base import * diff --git a/test/test_py_d/ts_shared.py b/test/test_py_d/ts_shared.py index 4ed43988..ff3c5d58 100755 --- a/test/test_py_d/ts_shared.py +++ b/test/test_py_d/ts_shared.py @@ -21,7 +21,7 @@ test.test_py_d.ts_shared: Shared methods for the test.py test suite """ import os -from mmgen.util import ymsg +from mmgen.util import ymsg,get_extension from mmgen.wallet import get_wallet_cls from ..include.common import * diff --git a/test/test_py_d/ts_tool.py b/test/test_py_d/ts_tool.py index c80a89f0..4ad9a189 100755 --- a/test/test_py_d/ts_tool.py +++ b/test/test_py_d/ts_tool.py @@ -10,6 +10,9 @@ test.test_py_d.ts_tool: tool tests for the MMGen test.py test suite """ +from mmgen.util import suf +from mmgen.color import cyan + from ..include.common import * from .ts_base import * from .ts_main import TestSuiteMain diff --git a/test/test_py_d/ts_wallet.py b/test/test_py_d/ts_wallet.py index 11a72fb9..29f0eef6 100755 --- a/test/test_py_d/ts_wallet.py +++ b/test/test_py_d/ts_wallet.py @@ -21,6 +21,7 @@ test.test_py_d.ts_wallet: Wallet conversion tests for the test.py test suite """ import os +from mmgen.util import capfirst from mmgen.wallet import get_wallet_cls from .common import * from .ts_base import * diff --git a/test/tooltest2.py b/test/tooltest2.py index e7d37f19..41ad6a4b 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -29,8 +29,12 @@ from decimal import Decimal import include.test_init -from mmgen.common import * from test.include.common import set_globals,end_msg,sample_text + +from mmgen.cfg import Config,gc +from mmgen.color import green,blue,purple,cyan +from mmgen.util import msg,msg_r,Msg,is_hex_str,async_run,die + from mmgen.bip39 import is_bip39_mnemonic from mmgen.baseconv import is_mmgen_mnemonic from mmgen.xmrseed import is_xmrseed diff --git a/test/unit_tests_d/ut_tx_deserialize.py b/test/unit_tests_d/ut_tx_deserialize.py index a315dd88..5eae4570 100755 --- a/test/unit_tests_d/ut_tx_deserialize.py +++ b/test/unit_tests_d/ut_tx_deserialize.py @@ -6,6 +6,7 @@ test/unit_tests_d/ut_tx_deserialize: TX deserialization unit tests for the MMGen import os,json +from mmgen.color import purple,cyan from mmgen.util import msg,Msg,Msg_r from mmgen.protocol import init_proto from mmgen.tx import CompletedTX