Skip to content

Commit

Permalink
Fix flakey test
Browse files Browse the repository at this point in the history
The test was flakey.
The key problem is that the LSPS-server send the list-protocols message
before the LSP-client could send the message
  • Loading branch information
ErikDeSmedt committed Aug 16, 2023
1 parent 11433fa commit 5609c4c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libs/gl-testing/tests/test_lsps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json

from glclient.lsps import ProtocolList
import time

import threading

Expand Down Expand Up @@ -34,6 +35,7 @@ def wrap_function(*args, **kwargs):
self._thread = threading.Thread(target=wrap_function, args=args, kwargs=kwargs)
self._thread.start()


def await_result(self, timeout_seconds : float=30.0):
self._thread.join(timeout=timeout_seconds)
if self._thread.is_alive():
Expand Down Expand Up @@ -68,6 +70,10 @@ def test_lsps_list_protocol(clients : Clients, node_factory : NodeFactory, bitco
json_rpc_id = "abcdef"
protocol_fut = AwaitResult(lambda: lsp_client.list_protocols(json_rpc_id=json_rpc_id))

# The sleep ensures the lsp-client has actually send the message and is ready to receive
# the response
time.sleep(1.0)

# The n1.rpc.sendcustommsg expects that both the node_id and msg are hex encoded strings
msg_content = {
"jsonrpc" : "2.0",
Expand Down

0 comments on commit 5609c4c

Please sign in to comment.