From e8186eeaa967a169d94c2d851d5ec7ab371f3074 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 5 Apr 2023 19:17:06 +0200 Subject: [PATCH] tests: fix a race in the reorg exclusion test --- tests/test_chain.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_chain.py b/tests/test_chain.py index 21623aef..6c7cba1d 100644 --- a/tests/test_chain.py +++ b/tests/test_chain.py @@ -71,14 +71,20 @@ def test_reorg_exclusion(lianad, bitcoind): c_spend_tx = spend_coins(lianad, bitcoind, [coin_c]) bitcoind.generate_block(1, wait_for_mempool=1) + # Make sure the transaction were confirmed >10 blocks ago, so bitcoind won't update the + # mempool during the reorg to the initial height. + bitcoind.generate_block(10) + # Reorg the chain down to the initial height, excluding all transactions. current_height = bitcoind.rpc.getblockcount() bitcoind.simple_reorg(initial_height, shift=-1) wait_for(lambda: lianad.rpc.getinfo()["block_height"] == current_height + 1) - # For a too deep reorg bitcoind doesn't update the mempool. The deposit transactions were - # dropped. And we discard the unconfirmed coins whose deposit tx isn't part of our mempool - # anymore: the coins must have been marked as unconfirmed and subsequently discarded. + # During a reorg, bitcoind doesn't update the mempool for blocks too deep (>10 confs). + # The deposit transactions were dropped. And we discard the unconfirmed coins whose deposit + # tx isn't part of our mempool anymore: the coins must have been marked as unconfirmed and + # subsequently discarded. + wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 0) wait_for(lambda: len(lianad.rpc.listcoins()["coins"]) == 0) # And if we now confirm everything, they'll be marked as such. The one that was 'spending'