From 86f263d2d4a686f04a1db689d318f1c89a36127e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 24 Sep 2021 20:07:04 +0000 Subject: [PATCH] minor cleanups --- mmgen/addr.py | 2 +- mmgen/globalvars.py | 4 ++-- test/unit_tests.py | 3 +-- test/unit_tests_d/ut_dep.py | 5 ++++- test/unit_tests_d/ut_scrypt.py | 10 ++++++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mmgen/addr.py b/mmgen/addr.py index 8716abce..1e74f303 100755 --- a/mmgen/addr.py +++ b/mmgen/addr.py @@ -275,7 +275,7 @@ class KeyGeneratorPython(KeyGenerator): def privnum2pubhex(self,numpriv,compressed=False): pko = ecdsa.SigningKey.from_secret_exponent(numpriv,self.secp256k1) # pubkey = x (32 bytes) + y (32 bytes) (unsigned big-endian) - pubkey = (pko.get_verifying_key().to_string()).hex() + pubkey = pko.get_verifying_key().to_string().hex() if compressed: # discard Y coord, replace with appropriate version byte # even y: <0, odd y: >0 -- https://bitcointalk.org/index.php?topic=129652.0 return ('03','02')[pubkey[-1] in '02468ace'] + pubkey[:64] diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index 6eb33487..4a74398b 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -138,7 +138,7 @@ class GlobalContext(Lockable): ) for k in ('linux','win','msys'): - if sys.platform[:len(k)] == k: + if sys.platform.startswith(k): platform = { 'linux':'linux', 'win':'win', 'msys':'win' }[k] break else: @@ -279,7 +279,7 @@ class GlobalContext(Lockable): key_generator = 2 # libsecp256k1 is default force_standalone_scrypt_module = False - # Scrypt params: 'id_num': [N, p, r] (N is an exponent of two) + # Scrypt params: 'id_num': [N, r, p] (N is an exponent of two) # NB: hashlib.scrypt in Python (>=v3.6) supports max N value of 14. This means that # for hash presets > 3 the standalone scrypt library must be used! hash_presets = { diff --git a/test/unit_tests.py b/test/unit_tests.py index 2bdd5f9c..ebfa25a4 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -20,7 +20,7 @@ test/unit_tests.py: Unit tests for the MMGen suite """ -import sys,os,time +import sys,os,time,importlib from include.tests_header import repo_root from mmgen.common import * @@ -116,7 +116,6 @@ def run_test(test,subtest=None): rdie(1,'Unit test {test!r} failed') try: - import importlib for test in (cmd_args or all_tests): if '.' in test: test,subtest = test.split('.') diff --git a/test/unit_tests_d/ut_dep.py b/test/unit_tests_d/ut_dep.py index c44941f9..ee30f0e5 100755 --- a/test/unit_tests_d/ut_dep.py +++ b/test/unit_tests_d/ut_dep.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.ut_rpc: dependency unit tests for the MMGen suite +test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite + + Test whether dependencies are installed and functional. + No data verification is performed. """ from mmgen.common import * diff --git a/test/unit_tests_d/ut_scrypt.py b/test/unit_tests_d/ut_scrypt.py index 04f3b349..d148230e 100755 --- a/test/unit_tests_d/ut_scrypt.py +++ b/test/unit_tests_d/ut_scrypt.py @@ -35,7 +35,7 @@ class unit_test(object): if opt.quiet: omsg_r('.') else: - msg_r(' password {:9} '.format(pw_disp)) + msg_r('\n password {:9} '.format(pw_disp)) ret = scrypt_hash_passphrase(pw,salt,'1').hex() assert ret == res, ret @@ -48,14 +48,15 @@ class unit_test(object): if opt.quiet: omsg_r('.') else: - msg_r(' {!r:3}: {!r:12} '.format(hp,g.hash_presets[hp])) + msg_r('\n {!r:3}: {!r:12} '.format(hp,g.hash_presets[hp])) st = time.time() ret = scrypt_hash_passphrase(pw,salt,hp).hex() t = time.time() - st vmsg(' {:0.4f} secs'.format(t)) assert ret == res, ret - if opt.quiet: silence() + if opt.quiet: + silence() g.force_standalone_scrypt_module = False vmsg('Passwords:') @@ -69,7 +70,8 @@ class unit_test(object): vmsg('Hash presets (standalone scrypt):') test_presets((1,2,3)) - if opt.quiet: end_silence() + if opt.quiet: + end_silence() msg('OK') return True