From c514ce4f6bcd8652f9a9302a6945eb8fd2d34fc9 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 13 Sep 2026 15:50:14 +0000 Subject: [PATCH] remove use of env var `MMGEN_TEST_SUITE` from production code --- examples/coin-daemon-info.py | 9 +-------- mmgen/cfg.py | 4 ++-- mmgen/fileutil.py | 4 ++-- mmgen/proto/cosmos/tx/protobuf.py | 5 ++--- mmgen/proto/rune/tx/unsigned.py | 2 +- test/modtest_d/rune.py | 2 +- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/examples/coin-daemon-info.py b/examples/coin-daemon-info.py index 858e236f..6835389f 100755 --- a/examples/coin-daemon-info.py +++ b/examples/coin-daemon-info.py @@ -18,14 +18,7 @@ examples/coin-daemon-info.py: # # Testing mode: # -# 1) From the MMGen repository root, start the mainnet test suite daemons as follows -# (note that Geth is the default testing daemon for ETH): -# -# test/start-coin-daemons.py btc ltc eth -# -# 2) Then run the script as follows: -# -# PYTHONPATH=. MMGEN_TEST_SUITE=1 examples/coin-daemon-info.py btc ltc eth +# test/cmdtest.py -e coin_daemon_info # # Live mode: # diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 3fd49677..d3ea66b4 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -565,7 +565,7 @@ class Config(Lockable): init_term(self) from .fileutil import check_or_create_dir - check_or_create_dir(self.data_dir_root) + check_or_create_dir(self, self.data_dir_root) from .util import wrap_ripemd160 wrap_ripemd160() # ripemd160 required by mmgen_cfg_file() in _set_cfg_from_cfg_file() @@ -602,7 +602,7 @@ class Config(Lockable): self._die_on_incompatible_opts() - check_or_create_dir(self.data_dir) + check_or_create_dir(self, self.data_dir) if self.debug and gc.prog_name != 'cmdtest.py': self.verbose = True diff --git a/mmgen/fileutil.py b/mmgen/fileutil.py index d5c88012..71bbbb9c 100755 --- a/mmgen/fileutil.py +++ b/mmgen/fileutil.py @@ -35,11 +35,11 @@ from .util import ( strip_comments, ) -def check_or_create_dir(path): +def check_or_create_dir(cfg, path): try: os.listdir(path) except: - if os.getenv('MMGEN_TEST_SUITE') and os.path.exists(path): # path is a link or regular file + if getattr(cfg, 'test_suite', False) and os.path.exists(path): # path is a link or regular file from subprocess import run run(['rm', '-rf', str(path)]) try: diff --git a/mmgen/proto/cosmos/tx/protobuf.py b/mmgen/proto/cosmos/tx/protobuf.py index 370e48b5..fff72913 100755 --- a/mmgen/proto/cosmos/tx/protobuf.py +++ b/mmgen/proto/cosmos/tx/protobuf.py @@ -134,7 +134,7 @@ class Tx(BaseMessage): return sha256(bytes(self.raw)).hexdigest() # raises exception on failure: - def verify_sig(self, proto, account_number, backend='secp256k1'): + def verify_sig(self, cfg, proto, account_number, backend='secp256k1'): sign_doc = SignDoc( bodyBytes = bytes(self.body), authInfoBytes = bytes(self.authInfo), @@ -150,8 +150,7 @@ class Tx(BaseMessage): if not verify_sig(sig, msghash, pubkey): raise ValueError('signature verification failed') case 'ecdsa': - import os - if not os.getenv('MMGEN_TEST_SUITE'): + if not cfg.test_suite: from ....util import die die(3, 'The `ecdsa` package is unsafe and may be used only in a testing environment') # ecdsa.keys.VerifyingKey.verify_digest(): diff --git a/mmgen/proto/rune/tx/unsigned.py b/mmgen/proto/rune/tx/unsigned.py index dc41467d..e5981cf0 100755 --- a/mmgen/proto/rune/tx/unsigned.py +++ b/mmgen/proto/rune/tx/unsigned.py @@ -58,7 +58,7 @@ class Unsigned(VmUnsigned, Completed, TxBase.Unsigned): tx = build_tx(self.cfg, self.proto, parms) self.serialized = bytes(tx).hex() self.coin_txid = CoinTxID(tx.txid) - tx.verify_sig(self.proto, o['account_number']) + tx.verify_sig(self.cfg, self.proto, o['account_number']) class AutomountUnsigned(TxBase.AutomountUnsigned, Unsigned): pass diff --git a/test/modtest_d/rune.py b/test/modtest_d/rune.py index 691c3fc3..b866509f 100755 --- a/test/modtest_d/rune.py +++ b/test/modtest_d/rune.py @@ -162,7 +162,7 @@ def test_tx(src, cfg, vec): vmsg('\n TX info:\n ' + '\n '.join(tx_info(tx, proto)) + '\n') - tx.verify_sig(proto, parms.account_number) + tx.verify_sig(cfg, proto, parms.account_number) pubkey = tx.authInfo.signerInfos[0].publicKey.key.data vec_txid2 = getattr(vec, 'txid2', None)