daemon, rpc.backends.requests, test suite: minor cleanups
This commit is contained in:
parent
97b7305d0b
commit
1de4ae63c1
9 changed files with 33 additions and 25 deletions
|
|
@ -413,7 +413,7 @@ class CoinDaemon(Daemon):
|
|||
|
||||
# user-set values take precedence
|
||||
self.datadir = os.path.abspath(datadir or cfg.daemon_data_dir or self.init_datadir())
|
||||
self.non_dfl_datadir = bool(datadir or cfg.daemon_data_dir or self.test_suite or self.network == 'regtest')
|
||||
self.has_non_dfl_datadir = bool(datadir or cfg.daemon_data_dir or self.test_suite or self.network == 'regtest')
|
||||
|
||||
# init_datadir() may have already initialized logdir
|
||||
self.logdir = os.path.abspath(getattr(self, 'logdir', self.datadir))
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ opts_data = {
|
|||
'options': """
|
||||
-- -h, --help Print this help message
|
||||
-- --, --longhelp Print help message for long (global) options
|
||||
-k -A, --no-addresses Print only secret keys, no addresses
|
||||
-k -A, --no-addresses Generate only secret keys, no addresses
|
||||
-- -c, --print-checksum Print address list checksum and exit
|
||||
-- -d, --outdir= d Output files to directory 'd' instead of working dir
|
||||
-- -e, --echo-passphrase Echo passphrase or mnemonic to screen upon entry
|
||||
|
|
@ -77,9 +77,9 @@ opts_data = {
|
|||
+ (default: {dmat})
|
||||
-- -U, --subwallet= U Generate {what} for subwallet 'U' (see SUBWALLETS
|
||||
+ below)
|
||||
-k -V, --viewkeys Print viewkeys, omitting secret keys
|
||||
-k -V, --viewkeys Generate viewkeys, omitting spend keys
|
||||
-- -v, --verbose Produce more verbose output
|
||||
-k -x, --b16 Print secret keys in hexadecimal too
|
||||
-k -x, --b16 Generate secret keys in hexadecimal too
|
||||
""",
|
||||
'notes': """
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class bitcoin_core_daemon(CoinDaemon):
|
|||
self.rpc_password = MMGenRegtest.rpc_password
|
||||
|
||||
self.shared_args = list_gen(
|
||||
[f'--datadir={self.datadir}', self.nonstd_datadir or self.non_dfl_datadir],
|
||||
[f'--datadir={self.datadir}', self.nonstd_datadir or self.has_non_dfl_datadir],
|
||||
[f'--rpcport={self.rpc_port}'],
|
||||
[f'--rpcuser={self.rpc_user}', self.network == 'regtest'],
|
||||
[f'--rpcpassword={self.rpc_password}', self.network == 'regtest'],
|
||||
|
|
@ -74,7 +74,7 @@ class bitcoin_core_daemon(CoinDaemon):
|
|||
['--keypool=1'],
|
||||
['--rpcallowip=127.0.0.1'],
|
||||
[f'--rpcbind=127.0.0.1:{self.rpc_port}'],
|
||||
['--pid='+self.pidfile, self.use_pidfile],
|
||||
[f'--pid={self.pidfile}', self.use_pidfile],
|
||||
['--daemon', gc.platform in ('linux', 'darwin') and not self.opt.no_daemonize],
|
||||
['--fallbackfee=0.0002', self.coin == 'BTC' and self.network == 'regtest'],
|
||||
['--deprecatedrpc=create_bdb', self.coin == 'BTC' and self.opt.bdb_wallet],
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ class openethereum_daemon(ethereum_daemon):
|
|||
['--no-secretstore'],
|
||||
[f'--jsonrpc-port={self.rpc_port}'],
|
||||
[f'--port={self.p2p_port}', self.p2p_port],
|
||||
[f'--base-path={self.datadir}', self.non_dfl_datadir],
|
||||
[f'--base-path={self.datadir}', self.has_non_dfl_datadir],
|
||||
[f'--chain={self.proto.chain_name}', self.network!='regtest'],
|
||||
['--config=dev', self.network=='regtest'], # no presets for mainnet or testnet
|
||||
['--mode=offline', self.test_suite or self.network=='regtest'],
|
||||
[f'--log-file={self.logfile}', self.non_dfl_datadir],
|
||||
[f'--log-file={self.logfile}', self.has_non_dfl_datadir],
|
||||
['daemon', self.use_pidfile],
|
||||
[self.pidfile, self.use_pidfile])
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ class geth_daemon(ethereum_daemon):
|
|||
[f'--port={self.p2p_port}', self.p2p_port], # geth binds p2p port even with --maxpeers=0
|
||||
[f'--discovery.port={self.p2p_port}', self.id == 'reth' and self.p2p_port],
|
||||
['--maxpeers=0', self.id == 'geth' and not self.opt.online],
|
||||
[f'--datadir={self.datadir}', self.non_dfl_datadir],
|
||||
[f'--datadir={self.datadir}', self.has_non_dfl_datadir],
|
||||
['--holesky', self.network=='testnet' and self.id == 'geth'],
|
||||
['--chain=holesky', self.network=='testnet' and self.id == 'reth'],
|
||||
['--dev', self.network=='regtest'])
|
||||
|
|
@ -157,7 +157,7 @@ class erigon_daemon(geth_daemon):
|
|||
[f'--port={self.p2p_port}', self.p2p_port],
|
||||
['--maxpeers=0', not self.opt.online],
|
||||
[f'--private.api.addr=127.0.0.1:{self.private_port}'],
|
||||
[f'--datadir={self.datadir}', self.non_dfl_datadir],
|
||||
[f'--datadir={self.datadir}', self.has_non_dfl_datadir],
|
||||
['--chain=goerli', self.network=='testnet'],
|
||||
[f'--torrent.port={self.torrent_ports.testnet}', self.network=='testnet'],
|
||||
['--chain=dev', self.network=='regtest'],
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class monero_daemon(CoinDaemon):
|
|||
self.coind_args = list_gen(
|
||||
['--hide-my-port'],
|
||||
['--no-igd'],
|
||||
[f'--data-dir={self.datadir}', self.non_dfl_datadir],
|
||||
[f'--data-dir={self.datadir}', self.has_non_dfl_datadir],
|
||||
[f'--pidfile={self.pidfile}', self.use_pidfile],
|
||||
['--detach', not (self.opt.no_daemonize or gc.platform=='win32')],
|
||||
['--offline', not self.opt.online])
|
||||
|
|
@ -90,13 +90,6 @@ class MoneroWalletDaemon(RPCDaemon):
|
|||
_reset_ok = ('debug', 'wait', 'pids', 'force_kill')
|
||||
test_suite_datadir = os.path.join('test', 'daemons', 'xmrtest', 'wallet_rpc')
|
||||
|
||||
def start(self, *args, **kwargs):
|
||||
try: # NB: required due to bug in v18.3.1: PID file not deleted on shutdown
|
||||
os.unlink(self.pidfile)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
super().start(*args, **kwargs)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
cfg,
|
||||
|
|
@ -170,7 +163,7 @@ class MoneroWalletDaemon(RPCDaemon):
|
|||
[f'--daemon-address={self.monerod_addr}', self.monerod_addr],
|
||||
[f'--daemon-port={self.monerod_port}', not self.monerod_addr],
|
||||
[f'--proxy={self.proxy}', self.proxy],
|
||||
[f'--pidfile={self.pidfile}', gc.platform == 'linux'],
|
||||
[f'--pidfile={self.pidfile}', self.use_pidfile],
|
||||
['--detach', not (self.opt.no_daemonize or gc.platform=='win32')],
|
||||
['--stagenet', self.network == 'testnet'],
|
||||
['--allow-mismatched-daemon-version', self.test_suite])
|
||||
|
|
@ -180,3 +173,10 @@ class MoneroWalletDaemon(RPCDaemon):
|
|||
cfg = self.cfg,
|
||||
daemon = self,
|
||||
test_connection = False)
|
||||
|
||||
def start(self, *args, **kwargs):
|
||||
try: # NB: required due to bug in v18.3.1: PID file not deleted on shutdown
|
||||
os.unlink(self.pidfile)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
super().start(*args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class requests(base):
|
|||
def __init__(self, caller):
|
||||
super().__init__(caller)
|
||||
import requests, urllib3
|
||||
urllib3.disable_warnings()
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
self.session = requests.Session()
|
||||
self.session.trust_env = False # ignore *_PROXY environment vars
|
||||
self.session.headers = caller.http_hdrs
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ class OpSubmit(OpWallet):
|
|||
# with the ‘stop_wallet’ command. Authentication to send a signed transaction is overkill
|
||||
# in any case: if an attacker has access to the online machine, and hence the transaction,
|
||||
# they can broadcast it to the network by some other means.
|
||||
#
|
||||
# RPC authentication for the wallet daemon in particular seems unnecessary, because without
|
||||
# the wallet password a potential attacker cannot open the wallet anyway to do anything
|
||||
# nasty. In future, an option should be added to disable it globally.
|
||||
disable_authentication = True # FIXME
|
||||
|
||||
def post_mount_action(self):
|
||||
|
|
|
|||
|
|
@ -875,7 +875,12 @@ class CmdTestXMRCompat(CmdTestXMRAutosign):
|
|||
if wait_signed:
|
||||
self._wait_signed(signable_desc)
|
||||
self.insert_device_online()
|
||||
t = self.spawn(f'mmgen-{op}', (opts or self.alice_opts) + self.autosign_opts + add_opts + args)
|
||||
t = self.spawn(
|
||||
f'mmgen-{op}',
|
||||
(opts or self.alice_opts)
|
||||
+ self.autosign_opts
|
||||
+ add_opts
|
||||
+ args)
|
||||
if '--abort' in opts:
|
||||
t.expect('(y/N): ', 'y')
|
||||
elif op == 'txcreate':
|
||||
|
|
|
|||
|
|
@ -274,10 +274,9 @@ class CmdTestXMRWallet(CmdTestBase):
|
|||
run(['mkdir', '-p', data.udir])
|
||||
run(f'rm -f {data.kafile}', shell=True)
|
||||
t = self.spawn(
|
||||
'mmgen-keygen', [
|
||||
'-q', '--accept-defaults', '--coin=xmr',
|
||||
f'--outdir={data.udir}', data.mmwords, data.kal_range
|
||||
],
|
||||
'mmgen-keygen',
|
||||
['--quiet', '--accept-defaults', '--coin=xmr', f'--outdir={data.udir}']
|
||||
+ [data.mmwords, data.kal_range],
|
||||
extra_desc = f'({capfirst(user)})')
|
||||
t.read()
|
||||
t.ok()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue