json-rpc: Restrict custommsgs to be odd-typed

This solves a couple of issues with the need to synchronously drop the
connection in case we were required to understand what the peer was talking
about while still allowing users to experiment, just not kill connections.
This commit is contained in:
Christian Decker
2019-12-04 23:01:20 +01:00
parent 3af010f200
commit b18c1ea543
2 changed files with 16 additions and 0 deletions

View File

@@ -2096,6 +2096,12 @@ def test_sendcustommsg(node_factory):
with pytest.raises(RpcError, match=r'Cannot send messages of type 18 .WIRE_PING.'):
l2.rpc.dev_sendcustommsg(l2.info['id'], r'0012')
# The sendcustommsg RPC call is currently limited to odd-typed messages,
# since they will not result in disconnections or even worse channel
# failures.
with pytest.raises(RpcError, match=r'Cannot send even-typed [0-9]+ custom message'):
l2.rpc.dev_sendcustommsg(l2.info['id'], r'00FE')
# This should work since the peer is currently owned by `channeld`
l2.rpc.dev_sendcustommsg(l1.info['id'], msg)
l2.daemon.wait_for_log(