[tests] don't override __init__() in individual tests
[bitcoinplatinum.git] / test / functional / reindex.py
blob1f684a1afe3bf01dc15308e9e3ee9eaf5160988f
1 #!/usr/bin/env python3
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.
10 """
12 from test_framework.test_framework import BitcoinTestFramework
13 from test_framework.util import assert_equal
14 import time
16 class ReindexTest(BitcoinTestFramework):
18 def set_test_params(self):
19 self.setup_clean_chain = True
20 self.num_nodes = 1
22 def reindex(self, justchainstate=False):
23 self.nodes[0].generate(3)
24 blockcount = self.nodes[0].getblockcount()
25 self.stop_nodes()
26 extra_args = [["-reindex-chainstate" if justchainstate else "-reindex", "-checkblockindex=1"]]
27 self.start_nodes(extra_args)
28 while self.nodes[0].getblockcount() < blockcount:
29 time.sleep(0.1)
30 assert_equal(self.nodes[0].getblockcount(), blockcount)
31 self.log.info("Success")
33 def run_test(self):
34 self.reindex(False)
35 self.reindex(True)
36 self.reindex(False)
37 self.reindex(True)
39 if __name__ == '__main__':
40 ReindexTest().main()