Skip to content

Commit

Permalink
Add deferred_call_delay property, default to 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
roshii committed May 8, 2023
1 parent 5aa6619 commit 9e2dd80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/jmclient/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class WalletRPCTestBaseFB(WalletRPCTestBase):
class TrialTestWRPC_WS(WalletRPCTestBase, unittest.TestCase):
""" class for testing websocket subscriptions/events etc.
"""
# The number of seconds to wait before calling the function. (type: float or int )
deferred_call_delay = 0.3

def test_notif(self):
# simulate the daemon already having created
# a valid token (which it usually does when
Expand All @@ -180,7 +183,7 @@ def test_notif(self):
"ws://127.0.0.1:"+str(self.wss_port))
self.client_factory.protocol = ClientTProtocol
self.client_connector = connectWS(self.client_factory)
d = task.deferLater(reactor, 0.1, self.fire_tx_notif)
d = task.deferLater(reactor, self.deferred_call_delay, self.fire_tx_notif)
# 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
Expand All @@ -190,7 +193,7 @@ def test_notif(self):
return d

def wait_to_receive(self, res):
d = task.deferLater(reactor, 0.1, self.checkNotifs)
d = task.deferLater(reactor, self.deferred_call_delay, self.checkNotifs)
return d

def checkNotifs(self):
Expand Down
6 changes: 4 additions & 2 deletions test/jmclient/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class WebsocketTestBase(object):
"""
# the port for the ws (auto)
wss_port = None
# The number of seconds to wait before calling the function. (type: float or int )
deferred_call_delay = 0.3

def setUp(self):
if self.wss_port is None:
Expand All @@ -83,7 +85,7 @@ def do_test(self):
self.client_factory.protocol = ClientTProtocol
# keep track of the connector object so we can close it manually:
self.client_connector = connectWS(self.client_factory)
d = task.deferLater(reactor, 0.1, self.fire_tx_notif)
d = task.deferLater(reactor, self.deferred_call_delay, self.fire_tx_notif)
# 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
Expand All @@ -92,7 +94,7 @@ def do_test(self):
return d

def wait_to_receive(self, res):
d = task.deferLater(reactor, 0.1, self.checkNotifs)
d = task.deferLater(reactor, self.deferred_call_delay, self.checkNotifs)
return d

def checkNotifs(self):
Expand Down

0 comments on commit 9e2dd80

Please sign in to comment.