|
|
@@ -46,6 +46,13 @@ class CmdTestOpts(CmdTestBase):
|
|
|
('opt_good22', (41, 'good cmdline opt (opt + negated opt [substring])', [])),
|
|
|
('opt_good23', (41, 'good cmdline opt (negated negative opt [substring])', [])),
|
|
|
('opt_good24', (41, 'good cmdline opt (negated opt + opt [substring])', [])),
|
|
|
+ ('opt_good25', (41, 'good cmdline opt (--btc-rpc-host)', [])),
|
|
|
+ ('opt_good26', (41, 'good cmdline opt (--btc-rpc-port)', [])),
|
|
|
+ ('opt_good27', (41, 'good cmdline opt (--btc-ignore-daemon-version)', [])),
|
|
|
+ ('opt_good28', (41, 'good cmdline opt (--bch-cashaddr)', [])),
|
|
|
+ ('opt_good29', (41, 'good cmdline opt (--etc-max-tx-fee=0.1)', [])),
|
|
|
+ ('opt_good30', (41, 'good cmdline opt (--eth-chain-names=foo,bar)', [])),
|
|
|
+ ('opt_good31', (41, 'good cmdline opt (--xmr-rpc-port=28081)', [])),
|
|
|
('opt_bad_param', (41, 'bad global opt (--pager=1)', [])),
|
|
|
('opt_bad_infile', (41, 'bad infile parameter', [])),
|
|
|
('opt_bad_outdir', (41, 'bad outdir parameter', [])),
|
|
|
@@ -65,15 +72,42 @@ class CmdTestOpts(CmdTestBase):
|
|
|
('opt_invalid_14', (41, 'invalid cmdline opt (long opt substring too short)', [])),
|
|
|
('opt_invalid_15', (41, 'invalid cmdline (too many args)', [])),
|
|
|
('opt_invalid_16', (41, 'invalid cmdline (overlong arg)', [])),
|
|
|
+ ('opt_invalid_17', (41, 'invalid cmdline opt (--btc-rpc-host without ‘need_proto’)', [])),
|
|
|
+ ('opt_invalid_18', (41, 'invalid cmdline opt (--btc-rpc-port without ‘need_proto’)', [])),
|
|
|
+ ('opt_invalid_19', (41, 'invalid cmdline opt (--btc-rpc-port with non-integer param)', [])),
|
|
|
+ ('opt_invalid_21', (41, 'invalid cmdline opt (--btc-foo)', [])),
|
|
|
+ ('opt_invalid_22', (41, 'invalid cmdline opt (--btc-rpc-host with missing param)', [])),
|
|
|
+ ('opt_invalid_23', (41, 'invalid cmdline opt (--btc-ignore-daemon-version with param)', [])),
|
|
|
+ ('opt_invalid_24', (41, 'invalid cmdline opt (--bch-cashaddr without ‘need_proto’)', [])),
|
|
|
+ ('opt_invalid_25', (41, 'invalid cmdline opt (--bch-cashaddr without parameter)', [])),
|
|
|
+ ('opt_invalid_26', (41, 'invalid cmdline opt (--bch-cashaddr with non-bool parameter)', [])),
|
|
|
+ ('opt_invalid_27', (41, 'invalid cmdline opt (--ltc-cashaddr)', [])),
|
|
|
+ ('opt_invalid_28', (41, 'invalid cmdline opt (--xmr-max-tx-fee)', [])),
|
|
|
+ ('opt_invalid_29', (41, 'invalid cmdline opt (--eth-max-tx-fee without parameter)', [])),
|
|
|
+ ('opt_invalid_30', (41, 'invalid cmdline opt (--eth-max-tx-fee with non-numeric parameter)', [])),
|
|
|
+ ('opt_invalid_31', (41, 'invalid cmdline opt (--bch-cashaddr without --coin=bch)', [])),
|
|
|
+ ('opt_invalid_32', (41, 'invalid cmdline opt (--eth-chain-names without --coin=eth)', [])),
|
|
|
+ ('opt_invalid_33', (41, 'invalid cmdline opt (--xmr-rpc-host)', [])),
|
|
|
+ ('opt_invalid_34', (41, 'invalid cmdline opt (--eth-rpc-user)', [])),
|
|
|
)
|
|
|
|
|
|
- def spawn_prog(self, args, exit_val=None):
|
|
|
- return self.spawn('test/misc/opts.py', args, cmd_dir='.', exit_val=exit_val)
|
|
|
-
|
|
|
- def check_vals(self, args, vals):
|
|
|
- t = self.spawn_prog(args)
|
|
|
- for k, v in vals:
|
|
|
- t.expect(rf'{k}:\s+{v}', regex=True)
|
|
|
+ def spawn_prog(self, args, opts=[], exit_val=None, need_proto=False):
|
|
|
+ return self.spawn(
|
|
|
+ 'test/misc/opts.py',
|
|
|
+ opts + args,
|
|
|
+ cmd_dir = '.',
|
|
|
+ exit_val = exit_val,
|
|
|
+ env = {'TEST_MISC_OPTS_NEEDS_PROTO': '1' if need_proto else ''})
|
|
|
+
|
|
|
+ def check_vals(self, args, vals, check=True, need_proto=False):
|
|
|
+ show_opts = [a.removeprefix('cfg.') for a, b in vals if a.startswith('cfg.')]
|
|
|
+ t = self.spawn_prog(
|
|
|
+ args,
|
|
|
+ opts = ['--show-opts=' + ','.join(show_opts)] if show_opts else [],
|
|
|
+ need_proto = need_proto)
|
|
|
+ if check:
|
|
|
+ for k, v in vals:
|
|
|
+ t.expect(rf'{k}:\s+{v}', regex=True)
|
|
|
return t
|
|
|
|
|
|
def do_run(self, args, expect, exit_val, regex=False):
|
|
|
@@ -232,6 +266,45 @@ class CmdTestOpts(CmdTestBase):
|
|
|
def opt_good24(self):
|
|
|
return self.check_vals(['--no-pag', '--pag'], (('cfg.pager', 'True'),))
|
|
|
|
|
|
+ def opt_good25(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--btc-rpc-host=pi5'],
|
|
|
+ (('cfg.btc_rpc_host', 'pi5'), ('proto.rpc_host', 'pi5')),
|
|
|
+ need_proto=True)
|
|
|
+
|
|
|
+ def opt_good26(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--btc-rpc-port=7272'],
|
|
|
+ (('cfg.btc_rpc_port', '7272'), ('proto.rpc_port', '7272')),
|
|
|
+ need_proto=True)
|
|
|
+
|
|
|
+ def opt_good27(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--btc-ignore-daemon-version'],
|
|
|
+ (('cfg.btc_ignore_daemon_version', 'True'), ('proto.ignore_daemon_version', 'True'),),
|
|
|
+ need_proto = True)
|
|
|
+
|
|
|
+ def opt_good28(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--coin=bch', '--bch-cashaddr=yes'],
|
|
|
+ (('cfg.bch_cashaddr', 'True'), ('proto.cashaddr', 'True'),),
|
|
|
+ need_proto = True)
|
|
|
+
|
|
|
+ def opt_good29(self):
|
|
|
+ return self.check_vals(['--etc-max-tx-fee=0.1'], (('cfg.etc_max_tx_fee', '0.1'),), need_proto=True)
|
|
|
+
|
|
|
+ def opt_good30(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--coin=eth', '--eth-mainnet-chain-names=foo,bar'],
|
|
|
+ (('cfg.eth_mainnet_chain_names', r"\['foo', 'bar'\]"), ('proto.chain_names', r"\['foo', 'bar'\]")),
|
|
|
+ need_proto = True)
|
|
|
+
|
|
|
+ def opt_good31(self):
|
|
|
+ return self.check_vals(
|
|
|
+ ['--coin=xmr', '--xmr-rpc-port=28081'],
|
|
|
+ (('cfg.xmr_rpc_port', '28081'),('proto.rpc_port', '28081'),),
|
|
|
+ need_proto = True)
|
|
|
+
|
|
|
def opt_bad_param(self):
|
|
|
return self.do_run(['--pager=1'], 'no parameter', 1)
|
|
|
|
|
|
@@ -249,49 +322,100 @@ class CmdTestOpts(CmdTestBase):
|
|
|
def opt_bad_autoset(self):
|
|
|
return self.do_run(['--fee-estimate-mode=Fubar'], 'not unique substring', 1)
|
|
|
|
|
|
- def opt_invalid(self, args, expect, exit_val):
|
|
|
- t = self.spawn_prog(args, exit_val=exit_val)
|
|
|
+ def opt_invalid(self, args, expect, opts=[], need_proto=False, exit_val=1):
|
|
|
+ t = self.spawn_prog(args, opts=opts, exit_val=exit_val, need_proto=need_proto)
|
|
|
t.expect(expect)
|
|
|
return t
|
|
|
|
|
|
def opt_invalid_1(self):
|
|
|
- return self.opt_invalid(['--x'], 'must be at least', 1)
|
|
|
+ return self.opt_invalid(['--x'], 'must be at least')
|
|
|
|
|
|
def opt_invalid_2(self):
|
|
|
- return self.opt_invalid(['---'], 'must be at least', 1)
|
|
|
+ return self.opt_invalid(['---'], 'must be at least')
|
|
|
|
|
|
def opt_invalid_5(self):
|
|
|
- return self.opt_invalid(['-l'], 'missing parameter', 1)
|
|
|
+ return self.opt_invalid(['-l'], 'missing parameter')
|
|
|
|
|
|
def opt_invalid_6(self):
|
|
|
- return self.opt_invalid(['-l', '-k'], 'missing parameter', 1)
|
|
|
+ return self.opt_invalid(['-l', '-k'], 'missing parameter')
|
|
|
|
|
|
def opt_invalid_7(self):
|
|
|
- return self.opt_invalid(['--quiet=1'], 'requires no parameter', 1)
|
|
|
+ return self.opt_invalid(['--quiet=1'], 'requires no parameter')
|
|
|
|
|
|
def opt_invalid_8(self):
|
|
|
- return self.opt_invalid(['-w'], 'unrecognized option', 1)
|
|
|
+ return self.opt_invalid(['-w'], 'unrecognized option')
|
|
|
|
|
|
def opt_invalid_9(self):
|
|
|
- return self.opt_invalid(['--frobnicate'], 'unrecognized option', 1)
|
|
|
+ return self.opt_invalid(['--frobnicate'], 'unrecognized option')
|
|
|
|
|
|
def opt_invalid_10(self):
|
|
|
- return self.opt_invalid(['--label', '-q'], 'missing parameter', 1)
|
|
|
+ return self.opt_invalid(['--label', '-q'], 'missing parameter')
|
|
|
|
|
|
def opt_invalid_11(self):
|
|
|
- return self.opt_invalid(['-T', '-10'], 'missing parameter', 1)
|
|
|
+ return self.opt_invalid(['-T', '-10'], 'missing parameter')
|
|
|
|
|
|
def opt_invalid_12(self):
|
|
|
- return self.opt_invalid(['-q', '-10'], 'unrecognized option', 1)
|
|
|
+ return self.opt_invalid(['-q', '-10'], 'unrecognized option')
|
|
|
|
|
|
def opt_invalid_13(self):
|
|
|
- return self.opt_invalid(['--mi=3'], 'ambiguous option', 1)
|
|
|
+ return self.opt_invalid(['--mi=3'], 'ambiguous option')
|
|
|
|
|
|
def opt_invalid_14(self):
|
|
|
- return self.opt_invalid(['--m=3'], 'must be at least', 1)
|
|
|
+ return self.opt_invalid(['--m=3'], 'must be at least')
|
|
|
|
|
|
def opt_invalid_15(self):
|
|
|
- return self.opt_invalid(['m'] * 257, 'too many', 1)
|
|
|
+ return self.opt_invalid(['m'] * 257, 'too many')
|
|
|
|
|
|
def opt_invalid_16(self):
|
|
|
- return self.opt_invalid(['e' * 4097], 'too long', 1)
|
|
|
+ return self.opt_invalid(['e' * 4097], 'too long')
|
|
|
+
|
|
|
+ def opt_invalid_17(self):
|
|
|
+ return self.opt_invalid(['--btc-rpc-host'], 'unrecognized option')
|
|
|
+
|
|
|
+ def opt_invalid_18(self):
|
|
|
+ return self.opt_invalid(['--btc-rpc-port'], 'unrecognized option')
|
|
|
+
|
|
|
+ def opt_invalid_19(self):
|
|
|
+ return self.opt_invalid(['--btc-rpc-port=foo'], "must be of type 'int'", need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_21(self):
|
|
|
+ return self.opt_invalid(['--btc-foo'], 'unrecognized option')
|
|
|
+
|
|
|
+ def opt_invalid_22(self):
|
|
|
+ return self.opt_invalid(['--btc-rpc-host'], 'missing parameter', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_23(self):
|
|
|
+ return self.opt_invalid(['--btc-ignore-daemon-version=1'], 'requires no parameter', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_24(self):
|
|
|
+ return self.opt_invalid(['--bch-cashaddr'], 'unrecognized option')
|
|
|
+
|
|
|
+ def opt_invalid_25(self):
|
|
|
+ return self.opt_invalid(['--bch-cashaddr'], 'missing parameter', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_26(self):
|
|
|
+ return self.opt_invalid(['--bch-cashaddr=foo'], "must be of type 'bool'", need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_27(self):
|
|
|
+ return self.opt_invalid(['--ltc-cashaddr'], 'unrecognized option', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_28(self):
|
|
|
+ return self.opt_invalid(['--xmr-max-tx-fee=0.1'], 'unrecognized option', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_29(self):
|
|
|
+ return self.opt_invalid(['--eth-max-tx-fee'], 'missing parameter', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_30(self):
|
|
|
+ return self.opt_invalid(['--eth-max-tx-fee=true'], 'must be of type', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_31(self):
|
|
|
+ return self.opt_invalid(['--bch-cashaddr=true'], 'has no attribute', opts=['--show-opts=bch_cashaddr'], need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_32(self):
|
|
|
+ return self.opt_invalid(['--eth-chain-names=foo,bar'], 'unrecognized option', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_33(self):
|
|
|
+ return self.opt_invalid(['--xmr-rpc-host=solaris'], 'unrecognized option', need_proto=True)
|
|
|
+
|
|
|
+ def opt_invalid_34(self):
|
|
|
+ return self.opt_invalid(['--eth-rpc-user=bob'], 'unrecognized option', need_proto=True)
|