Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test reindex works on init after a db load failure"""7from test_framework.test_framework import BitcoinTestFramework8from test_framework.util import assert_equal9import os12class ReindexInitTest(BitcoinTestFramework):13def set_test_params(self):14self.num_nodes = 116def run_test(self):17node = self.nodes[0]18self.stop_nodes()20self.log.info("Removing the block index leads to init error")21self.cleanup_folder(node.blocks_path / "index")22node.assert_start_raises_init_error(23expected_msg=f"Error initializing block database.{os.linesep}"24"Please restart with -reindex or -reindex-chainstate to recover.",25)27self.log.info("Allowing the reindex should work fine")28self.start_node(0, extra_args=["-test=reindex_after_failure_noninteractive_yes"])29assert_equal(node.getblockcount(), 200)32if __name__ == "__main__":33ReindexInitTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.