diff --git a/summary/summary.py b/summary/summary.py index 14f5a64..e00734e 100755 --- a/summary/summary.py +++ b/summary/summary.py @@ -46,6 +46,7 @@ class PeerThread(threading.Thread): rpcpeers = plugin.rpc.listpeers() trace_availability(plugin, rpcpeers) plugin.persist.sync() + plugin.log("[PeerThread] Peerstate availability persisted and synced. Sleeping now..." , 'debug') time.sleep(plugin.avail_interval) except Exception as ex: plugin.log("[PeerThread] " + str(ex), 'warn') diff --git a/summary/test_summary.py b/summary/test_summary.py index 75b8245..2a5f4d8 100644 --- a/summary/test_summary.py +++ b/summary/test_summary.py @@ -25,16 +25,16 @@ def get_stub(): def test_summary_peer_thread(node_factory): - # in order to give the PeerThread a chance in a unit test - # we need to give it a low interval - opts = {'summary-availability-interval': 0.1} + # Set a low PeerThread interval so we can test quickly. + opts = {'summary-availability-interval': 0.5} opts.update(pluginopt) l1, l2 = node_factory.line_graph(2, opts=opts) # when s1 = l1.rpc.summary() l2.stop() # we stop l2 and - time.sleep(0.5) # wait a bit for the PeerThread to see it + l1.daemon.logsearch_start = len(l1.daemon.logs) + l1.daemon.wait_for_log(r".*availability persisted and synced.*") s2 = l1.rpc.summary() # then @@ -172,17 +172,18 @@ def test_summary_avail_leadwin(): # checks whether the peerstate is persistent def test_summary_persist(node_factory): - # in order to give the PeerThread a chance in a unit test - # we need to give it a low interval - opts = {'summary-availability-interval': 0.1, 'may_reconnect': True} + # Set a low PeerThread interval so we can test quickly. + opts = {'summary-availability-interval': 0.5, 'may_reconnect': True} opts.update(pluginopt) l1, l2 = node_factory.line_graph(2, opts=opts) # when - time.sleep(0.5) # wait a bit for the PeerThread to capture data + l1.daemon.wait_for_log(r".*availability persisted and synced.*") s1 = l1.rpc.summary() l1.restart() l1.connect(l2) + l1.daemon.logsearch_start = len(l1.daemon.logs) + l1.daemon.wait_for_log(r".*availability persisted and synced.*") s2 = l1.rpc.summary() # then