regtest: minor changes
This commit is contained in:
parent
cf4b1cf3f6
commit
6b73197679
3 changed files with 12 additions and 5 deletions
|
|
@ -541,6 +541,13 @@ class BitcoinDaemon(CoinDaemon):
|
|||
if self.platform == 'linux' and not 'no_daemonize' in self.flags:
|
||||
self.daemonize_args = ['--daemon']
|
||||
|
||||
if self.network == 'regtest':
|
||||
from mmgen.regtest import MMGenRegtest
|
||||
self.shared_args += [
|
||||
f'--rpcuser={MMGenRegtest.rpc_user}',
|
||||
f'--rpcpassword={MMGenRegtest.rpc_password}',
|
||||
'--regtest' ]
|
||||
|
||||
if self.daemon_id == 'btc':
|
||||
if self.network == 'regtest':
|
||||
self.coin_specific_coind_args = ['--fallbackfee=0.0002']
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ def init(opts_data=None,add_opts=None,init_opts=None,opt_filter=None,parse_only=
|
|||
g.coin = g.coin.upper() or 'BTC'
|
||||
g.token = g.token.upper() or None
|
||||
|
||||
if g.bob or g.alice or (g.prog_name == 'mmgen-regtest'):
|
||||
if g.prog_name == 'mmgen-regtest' or g.bob or g.alice:
|
||||
g.regtest = True
|
||||
g.rpc_host = 'localhost'
|
||||
g.data_dir = os.path.join(g.data_dir_root,'regtest',g.coin.lower(),('alice','bob')[g.bob])
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from subprocess import run,PIPE
|
|||
from .common import *
|
||||
from .protocol import init_proto
|
||||
from .daemon import CoinDaemon
|
||||
from .rpc import rpc_init
|
||||
|
||||
def create_data_dir(data_dir):
|
||||
try: os.stat(os.path.join(data_dir,'regtest'))
|
||||
|
|
@ -56,7 +57,6 @@ class MMGenRegtest(MMGenObject):
|
|||
|
||||
self.proto = init_proto(self.coin,regtest=True)
|
||||
self.d = CoinDaemon(self.coin+'_rt',test_suite=g.test_suite_regtest)
|
||||
self.d.usr_shared_args = [f'--rpcuser={self.rpc_user}', f'--rpcpassword={self.rpc_password}', '--regtest']
|
||||
|
||||
async def generate(self,blocks=1,silent=False):
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class MMGenRegtest(MMGenObject):
|
|||
|
||||
create_data_dir(self.d.datadir)
|
||||
|
||||
gmsg('Starting {} regtest setup'.format(self.coin))
|
||||
gmsg('Starting {} regtest setup'.format(self.coin.upper()))
|
||||
|
||||
gmsg('Creating miner wallet')
|
||||
self.start_daemon('miner')
|
||||
|
|
@ -145,7 +145,6 @@ class MMGenRegtest(MMGenObject):
|
|||
self.d.start(silent=silent)
|
||||
|
||||
async def rpc_call(self,*args):
|
||||
from .rpc import rpc_init
|
||||
rpc = await rpc_init(self.proto,backend=None,daemon=self.d,caller='regtest')
|
||||
return await rpc.call(*args)
|
||||
|
||||
|
|
@ -191,7 +190,8 @@ class MMGenRegtest(MMGenObject):
|
|||
async def cli(self,*args):
|
||||
import json
|
||||
from .rpc import json_encoder
|
||||
print(json.dumps(await self.rpc_call(*args),cls=json_encoder))
|
||||
ret = await self.rpc_call(*args)
|
||||
print(ret if type(ret) == str else json.dumps(ret,cls=json_encoder))
|
||||
|
||||
async def cmd(self,args):
|
||||
ret = getattr(self,args[0])(*args[1:])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue