MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_multiplexed_rpc

Function test_multiplexed_rpc

tests/test_misc.py:927–954  ·  view source on GitHub ↗

Test that we can do multiple RPCs which exit in different orders

(node_factory)

Source from the content-addressed store, hash-verified

925
926
927def test_multiplexed_rpc(node_factory):
928 """Test that we can do multiple RPCs which exit in different orders"""
929 l1 = node_factory.get_node()
930
931 sock = connect_unix(l1.rpc.socket_path)
932
933 # Neighbouring ones may be in or out of order.
934 commands = [
935 b'{"id":1,"jsonrpc":"2.0","method":"dev","params":["slowcmd",2000]}',
936 b'{"id":1,"jsonrpc":"2.0","method":"dev","params":["slowcmd",2000]}',
937 b'{"id":2,"jsonrpc":"2.0","method":"dev","params":["slowcmd",1500]}',
938 b'{"id":2,"jsonrpc":"2.0","method":"dev","params":["slowcmd",1500]}',
939 b'{"id":3,"jsonrpc":"2.0","method":"dev","params":["slowcmd",1000]}',
940 b'{"id":3,"jsonrpc":"2.0","method":"dev","params":["slowcmd",1000]}',
941 b'{"id":4,"jsonrpc":"2.0","method":"dev","params":["slowcmd",500]}',
942 b'{"id":4,"jsonrpc":"2.0","method":"dev","params":["slowcmd",500]}'
943 ]
944
945 sock.sendall(b'\n'.join(commands))
946
947 buff = b''
948
949 # They will return in the same order, since they start immediately
950 # (delaying completion should mean we don't see the other commands intermingled).
951 for i in commands:
952 obj, buff = l1.rpc._readobj(sock, buff)
953 assert obj['id'] == json.loads(i.decode("UTF-8"))['id']
954 sock.close()
955
956
957def test_malformed_rpc(node_factory):

Callers

nothing calls this directly

Calls 7

connect_unixFunction · 0.85
sendallMethod · 0.80
joinMethod · 0.80
_readobjMethod · 0.80
get_nodeMethod · 0.45
decodeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected