diff --git a/mmgen/daemon.py b/mmgen/daemon.py index 41b4d923..80246224 100755 --- a/mmgen/daemon.py +++ b/mmgen/daemon.py @@ -26,7 +26,7 @@ from collections import namedtuple from mmgen.exception import * from mmgen.common import * -class TestDaemon(MMGenObject): +class Daemon(MMGenObject): cfg_file_hdr = '' subclasses_must_implement = ('state','stop_cmd') @@ -82,9 +82,9 @@ class TestDaemon(MMGenObject): network = 'mainnet' me = MMGenObject.__new__( - MoneroTestDaemon if coinsym == 'xmr' - else EthereumTestDaemon if coinsym in ('eth','etc') - else BitcoinTestDaemon ) + MoneroDaemon if coinsym == 'xmr' + else EthereumDaemon if coinsym in ('eth','etc') + else BitcoinDaemon ) me.network_id = network_id me.coinsym = coinsym @@ -236,8 +236,8 @@ class TestDaemon(MMGenObject): for k in cls.subclasses_must_implement: assert k in subcls.__dict__, m.format(k,subcls.__name__) -class BitcoinTestDaemon(TestDaemon): - cfg_file_hdr = '# TestDaemon config file\n' +class BitcoinDaemon(Daemon): + cfg_file_hdr = '# BitcoinDaemon config file\n' def subclass_init(self): @@ -285,7 +285,7 @@ class BitcoinTestDaemon(TestDaemon): def stop_cmd(self): return self.cli_cmd('stop') -class MoneroTestDaemon(TestDaemon): +class MoneroDaemon(Daemon): @property def shared_args(self): @@ -313,7 +313,7 @@ class MoneroTestDaemon(TestDaemon): def stop_cmd(self): return [self.coind_exec] + self.shared_args + ['exit'] -class EthereumTestDaemon(TestDaemon): +class EthereumDaemon(Daemon): def subclass_init(self): # defaults: @@ -359,4 +359,4 @@ class EthereumTestDaemon(TestDaemon): else: return super().pid -TestDaemon.check_implement() +Daemon.check_implement() diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index da59613e..5dba51f4 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -114,7 +114,7 @@ import mmgen.altcoins.eth.tx from mmgen.txsign import txsign from mmgen.protocol import CoinProtocol,init_coin if g.test_suite: - from mmgen.daemon import TestDaemon + from mmgen.daemon import Daemon if opt.stealth_led: opt.led = True @@ -136,7 +136,7 @@ def check_daemons_running(): continue if g.test_suite: g.proto.daemon_data_dir = 'test/daemons/' + coin.lower() - g.rpc_port = TestDaemon(get_network_id(coin,g.testnet)).rpc_port + g.rpc_port = Daemon(get_network_id(coin,g.testnet)).rpc_port vmsg('Checking {} daemon'.format(coin)) try: rpc_init(reinit=True) @@ -199,7 +199,7 @@ def sign_tx_file(txfile,signed_txs): if g.proto.sign_mode == 'daemon': if g.test_suite: g.proto.daemon_data_dir = 'test/daemons/' + g.coin.lower() - g.rpc_port = TestDaemon(get_network_id(g.coin,g.testnet)).rpc_port + g.rpc_port = Daemon(get_network_id(g.coin,g.testnet)).rpc_port rpc_init(reinit=True) if txsign(tx,wfs,None,None): diff --git a/mmgen/regtest.py b/mmgen/regtest.py index e5faeeb2..9c629fb9 100755 --- a/mmgen/regtest.py +++ b/mmgen/regtest.py @@ -23,7 +23,7 @@ regtest: Coin daemon regression test mode setup and operations for the MMGen sui import os,time,shutil,re,json from subprocess import run,PIPE from mmgen.common import * -from mmgen.daemon import TestDaemon +from mmgen.daemon import Daemon # To enforce MMGen policy that all testing must ignore the user's ~/.bitcoin # dir, locate the daemon datadir under MMGen data_dir: @@ -43,7 +43,7 @@ def create_data_dir(data_dir): try: os.makedirs(data_dir) except: pass -class RegtestTestDaemon(MMGenObject): # mixin class +class RegtestDaemon(MMGenObject): # mixin class def generate(self,blocks=1,silent=False): @@ -134,9 +134,9 @@ class MMGenRegtest(MMGenObject): assert user is None or user in self.users,'{!r}: invalid user for regtest'.format(user) - d = TestDaemon(self.coin,self.data_dir,desc='regtest daemon',rpc_port=self.rpc_port) + d = Daemon(self.coin,self.data_dir,desc='regtest daemon',rpc_port=self.rpc_port) - type(d).generate = RegtestTestDaemon.generate + type(d).generate = RegtestDaemon.generate d.net_desc = self.coin.upper() d.usr_shared_args = self.daemon_shared_args() diff --git a/test/common.py b/test/common.py index 76189822..ac08acd5 100755 --- a/test/common.py +++ b/test/common.py @@ -174,11 +174,11 @@ def stop_test_daemons(*network_ids): def test_daemons_ops(*network_ids,op): if opt.no_daemon_autostart: return - from mmgen.daemon import TestDaemon + from mmgen.daemon import Daemon repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir))) silent = not opt.verbose and not (hasattr(opt,'exact_output') and opt.exact_output) for network_id in network_ids: - if network_id not in TestDaemon.network_ids: # silently ignore invalid IDs + if network_id not in Daemon.network_ids: # silently ignore invalid IDs continue datadir = '{}/test/daemons/{}'.format(repo_root,network_id.replace('_tn','')) - TestDaemon(network_id,datadir).cmd(op,silent=silent) + Daemon(network_id,datadir).cmd(op,silent=silent) diff --git a/test/start-coin-daemons.py b/test/start-coin-daemons.py index 64553fc3..f21a6288 100755 --- a/test/start-coin-daemons.py +++ b/test/start-coin-daemons.py @@ -3,7 +3,7 @@ import sys from tests_header import repo_root from mmgen.common import * -from mmgen.daemon import TestDaemon +from mmgen.daemon import Daemon from mmgen.regtest import MMGenRegtest action = g.prog_name.split('-')[0] @@ -32,7 +32,7 @@ Valid Regtest users: {ru} 'code': { 'options': lambda s: s.format(a=action.capitalize(),pn=g.prog_name), 'notes': lambda s: s.format( - nid=', '.join(TestDaemon.network_ids), + nid=', '.join(Daemon.network_ids), rid=', '.join(MMGenRegtest.coins), ru=', '.join(MMGenRegtest.users), ) @@ -47,7 +47,7 @@ if 'all' in cmd_args or 'no_xmr' in cmd_args: if opt.regtest_user: ids = MMGenRegtest.coins else: - ids = list(TestDaemon.network_ids) + ids = list(Daemon.network_ids) if cmd_args[0] == 'no_xmr': ids.remove('xmr') else: @@ -55,7 +55,7 @@ else: if not ids: opts.usage() for i in ids: - if i not in TestDaemon.network_ids: + if i not in Daemon.network_ids: die(1,'{!r}: invalid network ID'.format(i)) if 'eth' in ids and 'etc' in ids: @@ -70,7 +70,7 @@ for network_id in ids: d = MMGenRegtest(network_id,datadir).test_daemon(opt.regtest_user) else: datadir = '{}/test/daemons/{}'.format(repo_root,coin) - d = TestDaemon(network_id,datadir) + d = Daemon(network_id,datadir) d.debug = opt.debug d.wait = not opt.no_wait if opt.get_state: diff --git a/test/test.py b/test/test.py index 44869c5e..c3286a51 100755 --- a/test/test.py +++ b/test/test.py @@ -77,7 +77,7 @@ try: os.unlink(os.path.join(repo_root,'my.err')) except: pass from mmgen.common import * -from mmgen.daemon import TestDaemon +from mmgen.daemon import Daemon from test.common import * from test.test_py_d.common import * @@ -156,7 +156,7 @@ network_id = get_network_id(get_coin(),bool(_uopts.get('testnet'))) sys.argv.insert(1,'--data-dir=' + data_dir) sys.argv.insert(1,'--daemon-data-dir=test/daemons/' + get_coin()) -sys.argv.insert(1,'--rpc-port={}'.format(TestDaemon(network_id).rpc_port)) +sys.argv.insert(1,'--rpc-port={}'.format(Daemon(network_id).rpc_port)) # step 2: opts.init will create new data_dir in ./test (if not 'resume' or 'skip_deps'): usr_args = opts.init(opts_data) diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index 4aba6bf3..06276ce4 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -299,8 +299,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): ) def __init__(self,trunner,cfgs,spawn): - from mmgen.daemon import TestDaemon - self.rpc_port = TestDaemon(g.coin).rpc_port + from mmgen.daemon import Daemon + self.rpc_port = Daemon(g.coin).rpc_port os.environ['MMGEN_BOGUS_WALLET_DATA'] = '' return TestSuiteBase.__init__(self,trunner,cfgs,spawn) diff --git a/test/test_py_d/ts_ref_altcoin.py b/test/test_py_d/ts_ref_altcoin.py index 51b03a32..9d5f53c1 100755 --- a/test/test_py_d/ts_ref_altcoin.py +++ b/test/test_py_d/ts_ref_altcoin.py @@ -84,7 +84,7 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase): self.write_to_tmpfile(pwfile,dfl_wpasswd) pf = joinpath(self.tmpdir,pwfile) from mmgen.protocol import init_coin - from mmgen.daemon import TestDaemon + from mmgen.daemon import Daemon for k in ('bch','eth','mm1','etc'): coin,token = ('eth','mm1') if k == 'mm1' else (k,None) ref_subdir = self._get_ref_subdir_by_coin(coin) @@ -97,7 +97,7 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase): start_test_daemons(network_id) extra_opts += [ '--daemon-data-dir=test/daemons/bch', - '--rpc-port={}'.format(TestDaemon(network_id).rpc_port) ] + '--rpc-port={}'.format(Daemon(network_id).rpc_port) ] g.testnet = tn init_coin(coin) fn = TestSuiteRef.sources['ref_tx_file'][token or coin][bool(tn)] diff --git a/test/unit_tests_d/ut_tx_deserialize.py b/test/unit_tests_d/ut_tx_deserialize.py index b5c98936..7ae5d5fd 100755 --- a/test/unit_tests_d/ut_tx_deserialize.py +++ b/test/unit_tests_d/ut_tx_deserialize.py @@ -107,16 +107,16 @@ class unit_test(object): ('bch',False,'test/ref/460D4D-BCH[10.19764,tl=1320969600].rawtx') ) from mmgen.protocol import init_coin from mmgen.tx import MMGenTX - from mmgen.daemon import TestDaemon + from mmgen.daemon import Daemon print_info('test/ref/*rawtx','MMGen reference transactions') for n,(coin,tn,fn) in enumerate(fns): init_coin(coin,tn) g.proto.daemon_data_dir = 'test/daemons/' + g.coin.lower() - g.rpc_port = TestDaemon(coin + ('','_tn')[tn]).rpc_port + g.rpc_port = Daemon(coin + ('','_tn')[tn]).rpc_port rpc_init(reinit=True) test_tx(MMGenTX(fn).hex,fn,n+1) init_coin('btc',False) - g.rpc_port = TestDaemon('btc').rpc_port + g.rpc_port = Daemon('btc').rpc_port rpc_init(reinit=True) Msg('OK')