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) 2022-present 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 that unsupported utxo db causes an init error.7Previous releases are required by this test, see test/README.md.8"""10import shutil12from test_framework.test_framework import BitcoinTestFramework13from test_framework.util import assert_equal16class UnsupportedUtxoDbTest(BitcoinTestFramework):17def set_test_params(self):18self.setup_clean_chain = True19self.num_nodes = 221def skip_test_if_missing_module(self):22self.skip_if_no_previous_releases()24def setup_network(self):25self.add_nodes(26self.num_nodes,27versions=[28140300, # Last release with previous utxo db format29None, # For MiniWallet, without migration code30],31)33def run_test(self):34self.log.info("Create previous version (v0.14.3) utxo db")35self.start_node(0)36block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[-1]37assert_equal(self.nodes[0].getbestblockhash(), block)38assert_equal(self.nodes[0].gettxoutsetinfo()["total_amount"], 50)39self.stop_nodes()41self.log.info("Check init error")42legacy_utxos_dir = self.nodes[0].chain_path / "chainstate"43legacy_blocks_dir = self.nodes[0].blocks_path44recent_utxos_dir = self.nodes[1].chain_path / "chainstate"45recent_blocks_dir = self.nodes[1].blocks_path46shutil.copytree(legacy_utxos_dir, recent_utxos_dir)47shutil.copytree(legacy_blocks_dir, recent_blocks_dir)48self.nodes[1].assert_start_raises_init_error(49expected_msg="Error: Unsupported chainstate database format found. "50"Please restart with -reindex-chainstate. "51"This will rebuild the chainstate database.",52)54self.log.info("Drop legacy utxo db")55self.start_node(1, extra_args=["-reindex-chainstate"])56assert_equal(self.nodes[1].getbestblockhash(), block)57assert_equal(self.nodes[1].gettxoutsetinfo()["total_amount"], 50)60if __name__ == "__main__":61UnsupportedUtxoDbTest(__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.