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
|
@ -22,7 +22,7 @@ static struct command_result *json_helloworld(struct command *cmd,
|
||||||
if (!name)
|
if (!name)
|
||||||
name = name_option ? name_option : tal_strdup(tmpctx, "world");
|
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 *
|
static struct command_result *
|
||||||
|
|
|
@ -1412,15 +1412,15 @@ def test_libplugin(node_factory):
|
||||||
l1.rpc.check("helloworld")
|
l1.rpc.check("helloworld")
|
||||||
|
|
||||||
# Test commands
|
# Test commands
|
||||||
assert l1.rpc.call("helloworld") == "hello world"
|
assert l1.rpc.call("helloworld") == {"hello": "world"}
|
||||||
assert l1.rpc.call("helloworld", {"name": "test"}) == "hello test"
|
assert l1.rpc.call("helloworld", {"name": "test"}) == {"hello": "test"}
|
||||||
l1.stop()
|
l1.stop()
|
||||||
l1.daemon.opts["plugin"] = plugin
|
l1.daemon.opts["plugin"] = plugin
|
||||||
l1.daemon.opts["name"] = "test_opt"
|
l1.daemon.opts["name"] = "test_opt"
|
||||||
l1.start()
|
l1.start()
|
||||||
assert l1.rpc.call("helloworld") == "hello test_opt"
|
assert l1.rpc.call("helloworld") == {"hello": "test_opt"}
|
||||||
# But param takes over!
|
# 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
|
# Test hooks and notifications
|
||||||
l2 = node_factory.get_node()
|
l2 = node_factory.get_node()
|
||||||
|
@ -1460,7 +1460,7 @@ def test_libplugin_deprecated(node_factory):
|
||||||
'name-deprecated': 'test_opt depr',
|
'name-deprecated': 'test_opt depr',
|
||||||
'allow-deprecated-apis': True})
|
'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')
|
l1.rpc.help('testrpc-deprecated')
|
||||||
assert l1.rpc.call("testrpc-deprecated") == l1.rpc.getinfo()
|
assert l1.rpc.call("testrpc-deprecated") == l1.rpc.getinfo()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue