From 9ffaab7d2245661b7c5c01f562f6aad3ea9d1fcf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Jan 2023 11:55:58 +1030 Subject: [PATCH] pytest: fix race in test_bookkeeping_closing_subsat_htlcs With the next change (which, as a side-effect, speeds up listpeers), we seem to hit a race in this test. The bookkeeper doesn't get to process the final payment before the node is shutdown. Signed-off-by: Rusty Russell --- tests/test_bookkeeper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_bookkeeper.py b/tests/test_bookkeeper.py index ed31c27e9..9093f58df 100644 --- a/tests/test_bookkeeper.py +++ b/tests/test_bookkeeper.py @@ -81,6 +81,9 @@ def test_bookkeeping_closing_subsat_htlcs(node_factory, bitcoind, chainparams): l1.pay(l2, 222) l1.pay(l2, 4000000) + # Make sure l2 bookkeeper processes event before we stop it! + wait_for(lambda: len([e for e in l2.rpc.bkpr_listaccountevents()['events'] if e['tag'] == 'invoice']) == 3) + l2.stop() l1.rpc.close(l2.info['id'], 1) bitcoind.generate_block(5, wait_for_mempool=1)