test: Check that the GUI interactive reindex works
This commit is contained in:
4 files changed
+39
-2
No files matched your search
@@ -709,6 +709,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
|
|||||||
|
|
||||||
const std::vector<std::string> TEST_OPTIONS_DOC{
|
const std::vector<std::string> TEST_OPTIONS_DOC{
|
||||||
"addrman (use deterministic addrman)",
|
"addrman (use deterministic addrman)",
|
||||||
|
"reindex_after_failure_noninteractive_yes (When asked for a reindex after failure interactively, simulate as-if answered with 'yes')",
|
||||||
"bip94 (enforce BIP94 consensus rules)",
|
"bip94 (enforce BIP94 consensus rules)",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1737,10 +1737,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
args);
|
args);
|
||||||
if (status == ChainstateLoadStatus::FAILURE && !do_reindex && !ShutdownRequested(node)) {
|
if (status == ChainstateLoadStatus::FAILURE && !do_reindex && !ShutdownRequested(node)) {
|
||||||
// suggest a reindex
|
// suggest a reindex
|
||||||
bool do_retry = uiInterface.ThreadSafeQuestion(
|
bool do_retry{HasTestOption(args, "reindex_after_failure_noninteractive_yes") ||
|
||||||
|
uiInterface.ThreadSafeQuestion(
|
||||||
error + Untranslated(".\n\n") + _("Do you want to rebuild the databases now?"),
|
error + Untranslated(".\n\n") + _("Do you want to rebuild the databases now?"),
|
||||||
error.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
error.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
||||||
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT)};
|
||||||
if (!do_retry) {
|
if (!do_retry) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
"""Test reindex works on init after a db load failure"""
|
||||||
|
|
||||||
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
from test_framework.util import assert_equal
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
class ReindexInitTest(BitcoinTestFramework):
|
||||||
|
def set_test_params(self):
|
||||||
|
self.num_nodes = 1
|
||||||
|
|
||||||
|
def run_test(self):
|
||||||
|
node = self.nodes[0]
|
||||||
|
self.stop_nodes()
|
||||||
|
|
||||||
|
self.log.info("Removing the block index leads to init error")
|
||||||
|
shutil.rmtree(node.blocks_path / "index")
|
||||||
|
node.assert_start_raises_init_error(
|
||||||
|
expected_msg=f": Error initializing block database.{os.linesep}"
|
||||||
|
"Please restart with -reindex or -reindex-chainstate to recover.",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.log.info("Allowing the reindex should work fine")
|
||||||
|
self.start_node(0, extra_args=["-test=reindex_after_failure_noninteractive_yes"])
|
||||||
|
assert_equal(node.getblockcount(), 200)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
ReindexInitTest(__file__).main()
|
||||||
@@ -289,6 +289,7 @@ BASE_SCRIPTS = [
|
|||||||
'p2p_leak.py',
|
'p2p_leak.py',
|
||||||
'wallet_encryption.py',
|
'wallet_encryption.py',
|
||||||
'feature_dersig.py',
|
'feature_dersig.py',
|
||||||
|
'feature_reindex_init.py',
|
||||||
'feature_cltv.py',
|
'feature_cltv.py',
|
||||||
'rpc_uptime.py',
|
'rpc_uptime.py',
|
||||||
'feature_discover.py',
|
'feature_discover.py',
|
||||||
|
|||||||
Reference in new issue
Block a user