Browse Source

pytest: Add failing test with JSON-RPC requests crossing each other

Suggested-By: @ZmnSCPxj
Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
cab7e3e43a
  1. 31
      tests/test_lightningd.py

31
tests/test_lightningd.py

@ -3410,20 +3410,29 @@ class LightningDTests(BaseLightningDTests):
def test_multirpc(self): def test_multirpc(self):
"""Test that we can do multiple RPC without waiting for response""" """Test that we can do multiple RPC without waiting for response"""
l1,l2 = self.connect() l1 = self.node_factory.get_node()
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(l1.rpc.socket_path) sock.connect(l1.rpc.socket_path)
sock.sendall(b'{"id":1,"jsonrpc":"2.0","method":"listpeers","params":[]}\n'
b'{"id":2,"jsonrpc":"2.0","method":"listpeers","params":[]}\n' commands = [
b'{"id":3,"jsonrpc":"2.0","method":"listpeers","params":[]}\n' b'{"id":1,"jsonrpc":"2.0","method":"listpeers","params":[]}',
b'{"id":4,"jsonrpc":"2.0","method":"listpeers","params":[]}\n' b'{"id":2,"jsonrpc":"2.0","method":"listpeers","params":[]}',
b'{"id":5,"jsonrpc":"2.0","method":"listpeers","params":[]}\n' b'{"id":3,"jsonrpc":"2.0","method":"listpeers","params":[]}',
b'{"id":6,"jsonrpc":"2.0","method":"listpeers","params":[]}\n') b'{"id":4,"jsonrpc":"2.0","method":"listpeers","params":[]}',
b'{"id":5,"jsonrpc":"2.0","method":"listpeers","params":[]}',
# This isn't quite right, as it will read the first object and stop. b'{"id":6,"jsonrpc":"2.0","method":"listpeers","params":[]}',
# But enough to trigger the crash! b'{"method": "invoice", "params": [100, "foo", "foo"], "jsonrpc": "2.0", "id": 7 }',
l1.rpc._readobj(sock) b'{"method": "waitinvoice", "params": ["foo"], "jsonrpc" : "2.0", "id": 8 }',
b'{"method": "delinvoice", "params": ["foo", "unpaid"], "jsonrpc" : "2.0", "id": 9 }',
]
sock.sendall(b'\n'.join(commands))
# We only care to get back enough results, not their content
for _ in commands:
l1.rpc._readobj(sock)
#time.sleep(1)
sock.close() sock.close()
def test_cli(self): def test_cli(self):

Loading…
Cancel
Save