mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
pytest: don't use command_success_str in test_libplugin.c
result should *always* be an object. This allows it to add fields without breaking the API. A command which returns "result" as a string is living in sin. This changes one of the two callers of "command_success_str". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ebe8f37400
commit
129d3f65e7
2 changed files with 6 additions and 6 deletions
|
@ -22,7 +22,7 @@ static struct command_result *json_helloworld(struct command *cmd,
|
|||
if (!name)
|
||||
name = name_option ? name_option : tal_strdup(tmpctx, "world");
|
||||
|
||||
return command_success_str(cmd, tal_fmt(tmpctx, "hello %s", name));
|
||||
return command_success(cmd, json_out_obj(cmd, "hello", name));
|
||||
}
|
||||
|
||||
static struct command_result *
|
||||
|
|
|
@ -1412,15 +1412,15 @@ def test_libplugin(node_factory):
|
|||
l1.rpc.check("helloworld")
|
||||
|
||||
# Test commands
|
||||
assert l1.rpc.call("helloworld") == "hello world"
|
||||
assert l1.rpc.call("helloworld", {"name": "test"}) == "hello test"
|
||||
assert l1.rpc.call("helloworld") == {"hello": "world"}
|
||||
assert l1.rpc.call("helloworld", {"name": "test"}) == {"hello": "test"}
|
||||
l1.stop()
|
||||
l1.daemon.opts["plugin"] = plugin
|
||||
l1.daemon.opts["name"] = "test_opt"
|
||||
l1.start()
|
||||
assert l1.rpc.call("helloworld") == "hello test_opt"
|
||||
assert l1.rpc.call("helloworld") == {"hello": "test_opt"}
|
||||
# But param takes over!
|
||||
assert l1.rpc.call("helloworld", {"name": "test"}) == "hello test"
|
||||
assert l1.rpc.call("helloworld", {"name": "test"}) == {"hello": "test"}
|
||||
|
||||
# Test hooks and notifications
|
||||
l2 = node_factory.get_node()
|
||||
|
@ -1460,7 +1460,7 @@ def test_libplugin_deprecated(node_factory):
|
|||
'name-deprecated': 'test_opt depr',
|
||||
'allow-deprecated-apis': True})
|
||||
|
||||
assert l1.rpc.call("helloworld") == "hello test_opt depr"
|
||||
assert l1.rpc.call("helloworld") == {"hello": "test_opt depr"}
|
||||
l1.rpc.help('testrpc-deprecated')
|
||||
assert l1.rpc.call("testrpc-deprecated") == l1.rpc.getinfo()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue