From 06c29c29ec1156b86c981e1ded4e31604063797d Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Fri, 6 Jan 2023 12:44:21 +0000 Subject: [PATCH] Keep trying to receive websocket notification in test This may or may not fix #1057 and other test failures. Since the network delay in receiving the message is unknown (but expected to be very small, usually), we keep trying to receive notification of the transaction message in the websocket test 10 times for a total of 2 seconds (on the assumption that if it takes longer than that, something else is wrong). --- jmclient/test/test_wallet_rpc.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jmclient/test/test_wallet_rpc.py b/jmclient/test/test_wallet_rpc.py index e37116c92..9d14c5d95 100644 --- a/jmclient/test/test_wallet_rpc.py +++ b/jmclient/test/test_wallet_rpc.py @@ -169,7 +169,8 @@ def test_notif(self): # create a small delay between the instruction to send # the notification, and the checking of its receipt, # otherwise the client will be queried before the notification - # arrived: + # arrived. We will try a few times before giving up. + self.attempt_receipt_counter = 0 d.addCallback(self.wait_to_receive) return d @@ -178,7 +179,13 @@ def wait_to_receive(self, res): return d def checkNotifs(self): - assert self.client_factory.notifs == 1 + if self.attempt_receipt_counter > 10: + assert False + if not self.client_factory.notifs == 1: + jlog.info("Failed to receive notification, waiting and trying again") + self.attempt_receipt_counter += 1 + d = task.deferLater(reactor, 0.2, self.checkNotifs) + return d def fire_tx_notif(self): self.daemon.wss_factory.sendTxNotification(self.test_tx,