mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
plugin: add in deprecated_api behavior and test
we also check that the node isn't running now, for extra pedancity
This commit is contained in:
parent
b25a8ba29d
commit
41b18050a0
2 changed files with 22 additions and 3 deletions
|
@ -1128,11 +1128,13 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req)
|
|||
name = opt->name + 2;
|
||||
if (opt->value->as_bool) {
|
||||
json_add_bool(req->stream, name, *opt->value->as_bool);
|
||||
continue;
|
||||
if (!deprecated_apis)
|
||||
continue;
|
||||
}
|
||||
if (opt->value->as_int) {
|
||||
json_add_s64(req->stream, name, *opt->value->as_int);
|
||||
continue;
|
||||
if (!deprecated_apis)
|
||||
continue;
|
||||
}
|
||||
if (opt->value->as_str) {
|
||||
json_add_string(req->stream, name, opt->value->as_str);
|
||||
|
|
|
@ -55,7 +55,7 @@ def test_option_types(node_factory):
|
|||
'plugin': plugin_path,
|
||||
'str_opt': 'ok',
|
||||
'int_opt': 22,
|
||||
'bool_opt': 1,
|
||||
'bool_opt': True,
|
||||
})
|
||||
|
||||
n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
|
||||
|
@ -82,6 +82,7 @@ def test_option_types(node_factory):
|
|||
}, expect_fail=True, may_fail=True)
|
||||
|
||||
# the node should fail to start, and we get a stderr msg
|
||||
assert not n.daemon.running
|
||||
assert n.daemon.is_in_stderr('bool_opt: ! does not parse as type bool')
|
||||
|
||||
# What happens if we give it a bad int-option?
|
||||
|
@ -93,8 +94,24 @@ def test_option_types(node_factory):
|
|||
}, may_fail=True, expect_fail=True)
|
||||
|
||||
# the node should fail to start, and we get a stderr msg
|
||||
assert not n.daemon.running
|
||||
assert n.daemon.is_in_stderr('--int_opt: notok does not parse as type int')
|
||||
|
||||
plugin_path = os.path.join(os.getcwd(), 'tests/plugins/options.py')
|
||||
n = node_factory.get_node(options={
|
||||
'plugin': plugin_path,
|
||||
'str_opt': 'ok',
|
||||
'int_opt': 22,
|
||||
'bool_opt': 1,
|
||||
})
|
||||
|
||||
n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
|
||||
n.daemon.is_in_log(r"option int_opt 22 <class 'int'>")
|
||||
n.daemon.is_in_log(r"option int_opt 22 <class 'str'>")
|
||||
n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
|
||||
n.daemon.is_in_log(r"option bool_opt true <class 'str'>")
|
||||
n.stop()
|
||||
|
||||
|
||||
def test_millisatoshi_passthrough(node_factory):
|
||||
""" Ensure that Millisatoshi arguments and return work.
|
||||
|
|
Loading…
Add table
Reference in a new issue