From 0d34f4916e3301682ef3dc022f2d7df86d6049cc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 21 Jul 2023 16:00:16 +0930 Subject: [PATCH] pytest: fix timeout in test_sql The logs show we're not waiting for the right transaction, so be explicit. ``` # Check that channels gets refreshed! scid = l1.get_channel_scid(l2) l1.rpc.setchannel(scid, feebase=123) wait_for(lambda: l3.rpc.sql("SELECT short_channel_id FROM channels WHERE base_fee_millisatoshi = 123;")['rows'] == [[scid]]) l3.daemon.wait_for_log("Refreshing channels...") l3.daemon.wait_for_log("Refreshing channel: {}".format(scid)) # This has to wait for the hold_invoice plugin to let go! l1.rpc.close(l2.info['id']) bitcoind.generate_block(13, wait_for_mempool=1) > wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 2) tests/test_plugin.py:4143: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ success = . at 0x7fde3b9cd3a0>, timeout = 180 def wait_for(success, timeout=TIMEOUT): start_time = time.time() interval = 0.25 while not success(): time_left = start_time + timeout - time.time() if time_left <= 0: > raise ValueError("Timeout while waiting for {}".format(success)) E ValueError: Timeout while waiting for . at 0x7fde3b9cd3a0> ``` Signed-off-by: Rusty Russell --- tests/test_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index fef82fa42..154dba47b 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -4138,8 +4138,8 @@ def test_sql(node_factory, bitcoind): l3.daemon.wait_for_log("Refreshing channel: {}".format(scid)) # This has to wait for the hold_invoice plugin to let go! - l1.rpc.close(l2.info['id']) - bitcoind.generate_block(13, wait_for_mempool=1) + txid = l1.rpc.close(l2.info['id'])['txid'] + bitcoind.generate_block(13, wait_for_mempool=txid) wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 2) assert len(l3.rpc.sql("SELECT * FROM channels;")['rows']) == 2 l3.daemon.wait_for_log("Deleting channel: {}".format(scid))