From 15f4e1405f9663050d7c8a6aa339ea04c194052d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 28 May 2022 19:41:43 +0000 Subject: [PATCH] minor changes and fixes --- mmgen/base_proto/bitcoin/tw/ctl.py | 6 +++--- mmgen/daemon.py | 8 ++++---- mmgen/data/version | 2 +- mmgen/main_addrimport.py | 6 ++++-- mmgen/proto/btc.py | 2 +- mmgen/proto/eth.py | 2 +- mmgen/rpc.py | 11 +++++++---- mmgen/tw/ctl.py | 3 ++- test/overlay/fakemods/rpc.py | 8 ++------ test/test.py | 2 +- test/test_py_d/ts_regtest.py | 5 +++-- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/mmgen/base_proto/bitcoin/tw/ctl.py b/mmgen/base_proto/bitcoin/tw/ctl.py index dff829f2..e6db771b 100755 --- a/mmgen/base_proto/bitcoin/tw/ctl.py +++ b/mmgen/base_proto/bitcoin/tw/ctl.py @@ -147,9 +147,9 @@ class BitcoinTrackingWallet(TrackingWallet): msg_r(f'{CR}Rescanning block: {block} ({n+1}/{len(blocks)})') # httplib seems to require fresh connection here, so specify timeout await self.rpc.call('rescanblockchain',block,block,timeout=60) - msg('\nRescan completed OK') + msg(f'\nAddress balance{suf(coin_addrs)} updated successfully') return True else: - msg('Imported address has no balance' if len(coin_addrs) == 1 else - 'Imported addresses have no balances' ) + msg('Address has no balance' if len(coin_addrs) == 1 else + 'Addresses have no balances' ) return True diff --git a/mmgen/daemon.py b/mmgen/daemon.py index 839ade4a..5df8d662 100755 --- a/mmgen/daemon.py +++ b/mmgen/daemon.py @@ -87,11 +87,11 @@ class Daemon(Lockable): def run_cmd(self,cmd,silent=False,is_daemon=False): - if is_daemon and not silent: - msg(f'Starting {self.desc} on port {self.bind_port}') - if self.debug: - msg(f'\nExecuting: {" ".join(cmd)}') + msg('\n\n') + + if self.debug or (is_daemon and not silent): + msg(f'Starting {self.desc} on port {self.bind_port}') if self.use_threads and is_daemon and not self.opt.no_daemonize: ret = self.exec_cmd_thread(cmd) diff --git a/mmgen/data/version b/mmgen/data/version index bf588547..6082c61e 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -13.2.dev3 +13.2.dev4 diff --git a/mmgen/main_addrimport.py b/mmgen/main_addrimport.py index 77f47ae6..b6c53f0c 100755 --- a/mmgen/main_addrimport.py +++ b/mmgen/main_addrimport.py @@ -97,8 +97,10 @@ def parse_cmd_args(rpc,cmd_args): if opt.addrlist: al = AddrList( proto = proto, - addrlist = get_lines_from_file(infile,f'non-{g.proj_name} addresses', - trim_comments = True) ) + addrlist = get_lines_from_file( + infile, + f'non-{g.proj_name} addresses', + trim_comments = True ) ) else: al = import_mmgen_list(infile) elif len(cmd_args) == 0 and opt.address: diff --git a/mmgen/proto/btc.py b/mmgen/proto/btc.py index e370a578..5d99a961 100755 --- a/mmgen/proto/btc.py +++ b/mmgen/proto/btc.py @@ -34,7 +34,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp _finfo(478559,'00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148','BCH',False), ] caps = ('rbf','segwit') - mmcaps = ('key','addr','rpc','tx') + mmcaps = ('key','addr','rpc_init','tx') base_coin = 'BTC' base_proto = 'Bitcoin' # From BIP173: witness version 'n' is stored as 'OP_n'. OP_0 is encoded as 0x00, diff --git a/mmgen/proto/eth.py b/mmgen/proto/eth.py index c4798b71..c5b8e565 100755 --- a/mmgen/proto/eth.py +++ b/mmgen/proto/eth.py @@ -31,7 +31,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1): chain_names = ['ethereum','foundation'] sign_mode = 'standalone' caps = ('token',) - mmcaps = ('key','addr','rpc','tx') + mmcaps = ('key','addr','rpc_init','tx') base_proto = 'Ethereum' avg_bdi = 15 ignore_daemon_version = False diff --git a/mmgen/rpc.py b/mmgen/rpc.py index ebd66338..4c4f86a0 100755 --- a/mmgen/rpc.py +++ b/mmgen/rpc.py @@ -466,11 +466,14 @@ def handle_unsupported_daemon_version(rpc,name,warn_only): option, in which case you proceed at your own risk. """,indent=' ')) -async def rpc_init(proto,backend=None,daemon=None,ignore_daemon_version=False): - - if not 'rpc' in proto.mmcaps: - die(1,f'Coin daemon operations not supported for {proto.name} protocol!') +async def rpc_init( + proto, + backend = None, + daemon = None, + ignore_daemon_version = False ): + if not 'rpc_init' in proto.mmcaps: + die(1,f'rpc_init() not supported for {proto.name} protocol!') cls = getattr( importlib.import_module(f'mmgen.base_proto.{proto.base_proto.lower()}.rpc'), diff --git a/mmgen/tw/ctl.py b/mmgen/tw/ctl.py index 90bfbbf8..9bd49edd 100755 --- a/mmgen/tw/ctl.py +++ b/mmgen/tw/ctl.py @@ -20,6 +20,8 @@ twctl: Tracking wallet control class for the MMGen suite """ +from collections import namedtuple + from ..globalvars import g from ..util import msg,dmsg,write_mode,base_proto_subclass,die from ..base_obj import AsyncInit @@ -251,7 +253,6 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit): if not mmaddr: mmaddr = f'{self.proto.base_coin.lower()}:{coinaddr}' - from collections import namedtuple return namedtuple('addr_info',['mmaddr','coinaddr'])( TwMMGenID(self.proto,mmaddr), coinaddr ) diff --git a/test/overlay/fakemods/rpc.py b/test/overlay/fakemods/rpc.py index b8f27a9b..bcc8035f 100644 --- a/test/overlay/fakemods/rpc.py +++ b/test/overlay/fakemods/rpc.py @@ -4,13 +4,9 @@ if os.getenv('MMGEN_BOGUS_UNSPENT_DATA'): rpc_init_orig = rpc_init - async def rpc_init(proto,backend=None,daemon=None,ignore_daemon_version=False): + async def rpc_init(*args,**kwargs): - ret = await rpc_init_orig( - proto = proto, - backend = backend, - daemon = daemon, - ignore_daemon_version = ignore_daemon_version ) + ret = await rpc_init_orig(*args,**kwargs) ret.blockcount = 1000000 diff --git a/test/test.py b/test/test.py index cf7c2c86..b066590b 100755 --- a/test/test.py +++ b/test/test.py @@ -981,7 +981,7 @@ class TestSuiteRunner(object): elif ret == 'ok': ok() self.cmd_total += 1 - elif ret == 'skip': + elif ret in ('skip','silent'): pass elif type(ret) == tuple and ret[0] == 'skip_warn': self.skipped_warnings.append( diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index ef857bb1..857eb6ca 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -338,7 +338,8 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): def setup(self): stop_test_daemons(self.proto.network_id,force=True,remove_datadir=True) - try: shutil.rmtree(joinpath(self.tr.data_dir,'regtest')) + from shutil import rmtree + try: rmtree(joinpath(self.tr.data_dir,'regtest')) except: pass t = self.spawn('mmgen-regtest',['-n','setup']) for s in ('Starting','Creating','Creating','Creating','Mined','Setup complete'): @@ -942,7 +943,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): sid = self._user_sid('bob') t = self.spawn('mmgen-tool',['--bob','rescan_address',f'{sid}:C:1']) t.expect('Found 1 unspent output') - t.expect('completed OK') + t.expect('updated successfully') return t def bob_rescan_blockchain(self,add_args,expect):