TestDaemon: use non-standard RPC ports
This commit is contained in:
parent
fe8fdabdab
commit
69890d831b
11 changed files with 53 additions and 26 deletions
|
|
@ -113,6 +113,8 @@ import mmgen.tx
|
|||
import mmgen.altcoins.eth.tx
|
||||
from mmgen.txsign import txsign
|
||||
from mmgen.protocol import CoinProtocol,init_coin
|
||||
if g.test_suite:
|
||||
from mmgen.test_daemon import TestDaemon
|
||||
|
||||
if opt.stealth_led: opt.led = True
|
||||
|
||||
|
|
@ -134,6 +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
|
||||
vmsg('Checking {} daemon'.format(coin))
|
||||
try:
|
||||
rpc_init(reinit=True)
|
||||
|
|
@ -196,6 +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
|
||||
rpc_init(reinit=True)
|
||||
|
||||
if txsign(tx,wfs,None,None):
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ test_daemon.py: Daemon control classes for MMGen test suite and regtest mode
|
|||
"""
|
||||
|
||||
from subprocess import run,PIPE
|
||||
from collections import namedtuple
|
||||
from mmgen.exception import *
|
||||
from mmgen.common import *
|
||||
|
||||
|
|
@ -30,6 +31,18 @@ class TestDaemon(MMGenObject):
|
|||
subclasses_must_implement = ('state','stop_cmd')
|
||||
|
||||
network_ids = ('btc','btc_tn','bch','bch_tn','ltc','ltc_tn','xmr')
|
||||
|
||||
cd = namedtuple('coin_data',['coin','coind_exec','cli_exec','conf_file','dfl_rpc','dfl_rpc_tn'])
|
||||
coins = {
|
||||
'btc': cd('Bitcoin', 'bitcoind', 'bitcoin-cli', 'bitcoin.conf', 8333,18333),
|
||||
'bch': cd('Bcash', 'bitcoind-abc','bitcoin-cli', 'bitcoin.conf', 8442,18442), # MMGen RPC dfls
|
||||
'ltc': cd('Litecoin', 'litecoind', 'litecoin-cli','litecoin.conf', 9333,19335),
|
||||
'xmr': cd('Monero', 'monerod', 'monerod', 'bitmonero.conf',18082,28082),
|
||||
'eth': cd('Ethereum', 'parity', 'parity', 'parity.conf', 8545,8545),
|
||||
'etc': cd('Ethereum Classic','parity', 'parity', 'parity.conf', 8545,8545)
|
||||
}
|
||||
port_shift = 1000
|
||||
|
||||
debug = False
|
||||
wait = True
|
||||
use_pidfile = True
|
||||
|
|
@ -83,12 +96,12 @@ class TestDaemon(MMGenObject):
|
|||
|
||||
self.pidfile = '{}/{}-daemon.pid'.format(self.datadir,self.network)
|
||||
|
||||
self.coin,self.coind_exec,self.cli_exec,self.conf_file = {
|
||||
'btc': ('Bitcoin', 'bitcoind', 'bitcoin-cli', 'bitcoin.conf'),
|
||||
'ltc': ('Litecoin','litecoind', 'litecoin-cli','litecoin.conf'),
|
||||
'bch': ('Bcash', 'bitcoind-abc','bitcoin-cli', 'bitcoin.conf'),
|
||||
'xmr': ('Monero', 'monerod', 'monerod', 'bitmonero.conf')
|
||||
}[self.coinsym]
|
||||
for k in self.coins[self.coinsym]._fields:
|
||||
setattr(self,k,getattr(self.coins[self.coinsym],k))
|
||||
|
||||
self.rpc_port = self.usr_rpc_port or (
|
||||
(self.dfl_rpc,self.dfl_rpc_tn)[self.network=='testnet'] + self.port_shift
|
||||
)
|
||||
|
||||
self.net_desc = '{} {}'.format(self.coin,self.network)
|
||||
self.subclass_init()
|
||||
|
|
@ -226,11 +239,16 @@ class BitcoinTestDaemon(TestDaemon):
|
|||
if self.network=='testnet':
|
||||
self.testnet_arg = ['--testnet']
|
||||
|
||||
self.shared_args = ['--datadir='+self.datadir]
|
||||
if self.usr_rpc_port:
|
||||
self.shared_args += ['--rpcport={}'.format(self.usr_rpc_port)]
|
||||
self.shared_args = [
|
||||
'--datadir={}'.format(self.datadir),
|
||||
'--rpcport={}'.format(self.rpc_port) ]
|
||||
|
||||
self.coind_args = [
|
||||
'--listen=0',
|
||||
'--keypool=1',
|
||||
'--rpcallowip=127.0.0.1',
|
||||
'--rpcbind=127.0.0.1:{}'.format(self.rpc_port) ]
|
||||
|
||||
self.coind_args = ['--listen=0','--keypool=1']
|
||||
if self.use_pidfile:
|
||||
self.coind_args += ['--pid='+self.pidfile]
|
||||
|
||||
|
|
@ -238,13 +256,7 @@ class BitcoinTestDaemon(TestDaemon):
|
|||
self.coind_args += ['--daemon']
|
||||
|
||||
if self.coinsym == 'bch':
|
||||
port = self.usr_rpc_port or (8442,18442)[self.network=='testnet']
|
||||
self.coin_specific_coind_args = [
|
||||
'--rpcallowip=127.0.0.1',
|
||||
'--rpcbind=127.0.0.1:{}'.format(port),
|
||||
'--usecashaddr=0' ]
|
||||
if not self.usr_rpc_port:
|
||||
self.coin_specific_cli_args = ['--rpcport={}'.format(port)]
|
||||
self.coin_specific_coind_args = ['--usecashaddr=0']
|
||||
elif self.coinsym == 'ltc':
|
||||
self.coin_specific_coind_args = ['--mempoolreplacement=1']
|
||||
|
||||
|
|
@ -266,7 +278,6 @@ class BitcoinTestDaemon(TestDaemon):
|
|||
return self.cli_cmd('stop')
|
||||
|
||||
class MoneroTestDaemon(TestDaemon):
|
||||
rpc_port = 18181
|
||||
|
||||
@property
|
||||
def shared_args(self):
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ else:
|
|||
if i not in TestDaemon.network_ids:
|
||||
die(1,'{!r}: invalid network ID'.format(i))
|
||||
|
||||
if 'eth' in ids and 'etc' in ids:
|
||||
msg('Cannot run ETH and ETC simultaneously, so skipping ETC')
|
||||
ids.remove('etc')
|
||||
|
||||
for network_id in ids:
|
||||
network_id = network_id.lower()
|
||||
coin = network_id.replace('_tn','')
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ t_xmr="
|
|||
"
|
||||
f_xmr='Monero tests completed'
|
||||
|
||||
mmgen_tool_xmr="$mmgen_tool --rpc-port=18181 -q --accept-defaults --outdir $TMPDIR"
|
||||
mmgen_tool_xmr="$mmgen_tool --rpc-port=19082 -q --accept-defaults --outdir $TMPDIR"
|
||||
|
||||
[ "$MSYS2" ] || { # password file descriptor issues, cannot use popen_spawn()
|
||||
t_xmr+="
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ try: os.unlink(os.path.join(repo_root,'my.err'))
|
|||
except: pass
|
||||
|
||||
from mmgen.common import *
|
||||
from mmgen.test_daemon import TestDaemon
|
||||
from test.common import *
|
||||
from test.test_py_d.common import *
|
||||
|
||||
|
|
@ -155,6 +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))
|
||||
|
||||
# step 2: opts.init will create new data_dir in ./test (if not 'resume' or 'skip_deps'):
|
||||
usr_args = opts.init(opts_data)
|
||||
|
|
|
|||
|
|
@ -291,7 +291,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
)
|
||||
|
||||
def __init__(self,trunner,cfgs,spawn):
|
||||
self.rpc_port = 8549
|
||||
from mmgen.test_daemon import TestDaemon
|
||||
self.rpc_port = TestDaemon(g.coin).rpc_port
|
||||
os.environ['MMGEN_BOGUS_WALLET_DATA'] = ''
|
||||
return TestSuiteBase.__init__(self,trunner,cfgs,spawn)
|
||||
|
||||
|
|
@ -602,7 +603,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
return self.token_compile(token_data)
|
||||
|
||||
def _rpc_init(self):
|
||||
g.proto.rpc_port = 8549
|
||||
g.proto.rpc_port = self.rpc_port
|
||||
rpc_init()
|
||||
|
||||
def token_deploy(self,num,key,gas,mmgen_cmd='txdo',tx_fee='8G'):
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
'basic operations with emulated tracking wallet'
|
||||
tmpdir_nums = [1,2,3,4,5,14,15,16,20,21]
|
||||
networks = ('btc','btc_tn','ltc','ltc_tn','bch','bch_tn')
|
||||
passthru_opts = ('daemon_data_dir','coin','testnet')
|
||||
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
||||
segwit_opts_ok = True
|
||||
cmd_group = (
|
||||
('walletgen_dfl_wallet', (15,'wallet generation (default wallet)',[[[],15]])),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TestSuiteHelp(TestSuiteBase):
|
|||
'help, info and usage screens'
|
||||
networks = ('btc','ltc','bch','eth')
|
||||
tmpdir_nums = []
|
||||
passthru_opts = ('daemon_data_dir','coin','testnet')
|
||||
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
||||
cmd_group = (
|
||||
('helpscreens', (1,'help screens', [])),
|
||||
('longhelpscreens', (1,'help screens (--longhelp)',[])),
|
||||
|
|
@ -257,7 +257,7 @@ class TestSuiteTool(TestSuiteMain,TestSuiteBase):
|
|||
class TestSuiteRefTX(TestSuiteMain,TestSuiteBase):
|
||||
'create a reference transaction file (administrative command)'
|
||||
segwit_opts_ok = False
|
||||
passthru_opts = ('daemon_data_dir','coin','testnet')
|
||||
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
||||
tmpdir_nums = [31,32,33,34]
|
||||
cmd_group = (
|
||||
('ref_tx_addrgen1', (31,'address generation (legacy)', [[[],1]])),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared):
|
|||
'saved reference address, password and transaction files'
|
||||
tmpdir_nums = [8]
|
||||
networks = ('btc','btc_tn','ltc','ltc_tn')
|
||||
passthru_opts = ('daemon_data_dir','coin','testnet')
|
||||
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
|
||||
sources = {
|
||||
'ref_addrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.addrs',
|
||||
'ref_segwitaddrfile':'98831F3A{}-S[1,31-33,500-501,1010-1011]{}.addrs',
|
||||
|
|
|
|||
|
|
@ -84,6 +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.test_daemon import TestDaemon
|
||||
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)
|
||||
|
|
@ -95,7 +96,8 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase):
|
|||
network_id = get_network_id('bch',tn)
|
||||
start_test_daemons(network_id)
|
||||
extra_opts += [
|
||||
'--daemon-data-dir=test/daemons/bch' ]
|
||||
'--daemon-data-dir=test/daemons/bch',
|
||||
'--rpc-port={}'.format(TestDaemon(network_id).rpc_port) ]
|
||||
g.testnet = tn
|
||||
init_coin(coin)
|
||||
fn = TestSuiteRef.sources['ref_tx_file'][token or coin][bool(tn)]
|
||||
|
|
|
|||
|
|
@ -107,13 +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.test_daemon import TestDaemon
|
||||
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
|
||||
rpc_init(reinit=True)
|
||||
test_tx(MMGenTX(fn).hex,fn,n+1)
|
||||
init_coin('btc',False)
|
||||
g.rpc_port = TestDaemon('btc').rpc_port
|
||||
rpc_init(reinit=True)
|
||||
Msg('OK')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue