lightningd: only use non-numeric JSON ids if plugin says we can.

We also remember whether the id is a string or not, for replacement in
JSON passthrough.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-11-21 12:18:32 +10:30
committed by Christian Decker
parent 24651f57ad
commit d5ce5cbab3
9 changed files with 84 additions and 47 deletions

View File

@@ -1501,8 +1501,9 @@ def test_libplugin(node_factory):
myname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
# Side note: getmanifest will trace back to plugin_start
l1.daemon.wait_for_log(r": {}:plugin#[0-9]*/cln:getmanifest#[0-9]*\[OUT\]".format(myname))
# Note: getmanifest always uses numeric ids, since it doesn't know
# yet whether strings are allowed:
l1.daemon.wait_for_log(r"test_libplugin: [0-9]*\[OUT\]")
# Test commands
assert l1.rpc.call("helloworld") == {"hello": "world"}
@@ -3237,3 +3238,18 @@ def test_block_added_notifications(node_factory, bitcoind):
sync_blockheight(bitcoind, [l2])
ret = l2.rpc.call("blockscatched")
assert len(ret) == 3 and ret[1] == next_l2_base + 1 and ret[2] == next_l2_base + 2
def test_numeric_json_ids(node_factory):
"""Test that we use numeric json IDs when in deprecated mode (unless
plugin says otherwise!)"""
l1 = node_factory.get_node(options={'allow-deprecated-apis': True,
'log-level': 'io'})
# getmanifest and init
l1.daemon.logsearch_start = 0
l1.daemon.wait_for_logs([r"plugin-commando: [0-9]*\[OUT\]"] * 2)
# This is in a plugin.
l1.rpc.commando_rune()
l1.daemon.wait_for_log(r"plugin-commando: [0-9]*\[OUT\]")