2 # Copyright (c) 2014-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test running bitcoind with -reindex and -reindex-chainstate options.
7 - Start a single node and generate 3 blocks.
8 - Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.
9 - Stop the node and restart it with -reindex-chainstate. Verify that the node has reindexed up to block 3.
12 from test_framework
.test_framework
import BitcoinTestFramework
13 from test_framework
.util
import assert_equal
16 class ReindexTest(BitcoinTestFramework
):
18 def set_test_params(self
):
19 self
.setup_clean_chain
= True
22 def reindex(self
, justchainstate
=False):
23 self
.nodes
[0].generate(3)
24 blockcount
= self
.nodes
[0].getblockcount()
26 extra_args
= [["-reindex-chainstate" if justchainstate
else "-reindex", "-checkblockindex=1"]]
27 self
.start_nodes(extra_args
)
28 while self
.nodes
[0].getblockcount() < blockcount
:
30 assert_equal(self
.nodes
[0].getblockcount(), blockcount
)
31 self
.log
.info("Success")
39 if __name__
== '__main__':