Merge #411: tests: fix a race in the reorg exclusion test

e8186eeaa967a169d94c2d851d5ec7ab371f3074 tests: fix a race in the reorg exclusion test (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  darosior:
    self-ACK e8186eeaa967a169d94c2d851d5ec7ab371f3074

Tree-SHA512: a18c88b488d0882a949ff49113cdf3549474448a12a764729b1308589302b36e630f74540bcf2f3733ee30cd9dbc05b833f387eb2ff32dd21907e2c71d814d8c
This commit is contained in:
Antoine Poinsot 2023-04-06 11:50:25 +02:00
commit 80c01510f4
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -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'