Skip to content

Commit a602f6f

Browse files
committed
test: index with an unclean restart after a reorg
This test fails without the previous commit.
1 parent 01b95ac commit a602f6f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/functional/feature_coinstatsindex.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,21 @@ def _test_init_index_after_reorg(self):
321321
res1 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=True)
322322
assert_equal(res["muhash"], res1["muhash"])
323323

324+
self.log.info("Test index with an unclean restart after a reorg")
325+
self.restart_node(1, extra_args=self.extra_args[1])
326+
committed_height = index_node.getblockcount()
327+
self.generate(index_node, 2, sync_fun=self.no_op)
328+
self.sync_index_node()
329+
block2 = index_node.getbestblockhash()
330+
index_node.invalidateblock(block2)
331+
self.generatetoaddress(index_node, 1, getnewdestination()[2], sync_fun=self.no_op)
332+
self.sync_index_node()
333+
index_node.kill_process()
334+
self.start_node(1, extra_args=self.extra_args[1])
335+
self.sync_index_node()
336+
# Because of the unclean shutdown above, indexes reset to the point we last committed them to disk.
337+
assert_equal(index_node.getindexinfo()['coinstatsindex']['best_block_height'], committed_height)
338+
324339

325340
if __name__ == '__main__':
326341
CoinStatsIndexTest(__file__).main()

0 commit comments

Comments
 (0)