test: index with an unclean restart after a reorg

This test fails without the previous commit.

Github-Pull: #33212
Rebased-From: a602f6fb7b
This commit is contained in:
Martin Zumsande 2025-08-18 21:21:48 +02:00 committed by Fabian Jahr
parent 16b1710d97
commit fcac8022d8
No known key found for this signature in database
GPG Key ID: F13D1E9D890798CD
1 changed files with 15 additions and 0 deletions

View File

@ -322,6 +322,21 @@ class CoinStatsIndexTest(BitcoinTestFramework):
res1 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=True) res1 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=True)
assert_equal(res["muhash"], res1["muhash"]) assert_equal(res["muhash"], res1["muhash"])
self.log.info("Test index with an unclean restart after a reorg")
self.restart_node(1, extra_args=self.extra_args[1])
committed_height = index_node.getblockcount()
self.generate(index_node, 2, sync_fun=self.no_op)
self.sync_index_node()
block2 = index_node.getbestblockhash()
index_node.invalidateblock(block2)
self.generatetoaddress(index_node, 1, getnewdestination()[2], sync_fun=self.no_op)
self.sync_index_node()
index_node.kill_process()
self.start_node(1, extra_args=self.extra_args[1])
self.sync_index_node()
# Because of the unclean shutdown above, indexes reset to the point we last committed them to disk.
assert_equal(index_node.getindexinfo()['coinstatsindex']['best_block_height'], committed_height)
if __name__ == '__main__': if __name__ == '__main__':
CoinStatsIndexTest(__file__).main() CoinStatsIndexTest(__file__).main()