Dash Core  0.12.2.1
P2P Digital Currency
reindex.py
Go to the documentation of this file.
1 #!/usr/bin/env python2
2 # Copyright (c) 2014-2015 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 
6 #
7 # Test -reindex and -reindex-chainstate with CheckBlockIndex
8 #
9 from test_framework.test_framework import BitcoinTestFramework
10 from test_framework.util import *
11 import time
12 
14 
15  def setup_chain(self):
16  print("Initializing test directory "+self.options.tmpdir)
17  initialize_chain_clean(self.options.tmpdir, 1)
18 
19  def setup_network(self):
20  self.nodes = []
21  self.is_network_split = False
22  self.nodes.append(start_node(0, self.options.tmpdir))
23 
24  def reindex(self, justchainstate=False):
25  self.nodes[0].generate(3)
26  blockcount = self.nodes[0].getblockcount()
27  stop_node(self.nodes[0], 0)
29  self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex-chainstate" if justchainstate else "-reindex", "-checkblockindex=1"])
30  while self.nodes[0].getblockcount() < blockcount:
31  time.sleep(0.1)
32  assert_equal(self.nodes[0].getblockcount(), blockcount)
33  print("Success")
34 
35  def run_test(self):
36  self.reindex(False)
37  self.reindex(True)
38  self.reindex(False)
39  self.reindex(True)
40 
41 if __name__ == '__main__':
42  ReindexTest().main()
def wait_bitcoinds()
Definition: util.py:337
UniValue getblockcount(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:131
def initialize_chain_clean(test_dir, num_nodes)
Definition: util.py:252
def setup_chain(self)
Definition: reindex.py:15
def reindex(self, justchainstate=False)
Definition: reindex.py:24
def run_test(self)
Definition: reindex.py:35
def setup_network(self)
Definition: reindex.py:19
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
Definition: util.py:281
def stop_node(node, i)
Definition: util.py:323
UniValue generate(const UniValue &params, bool fHelp)
Definition: mining.cpp:122
def assert_equal(thing1, thing2)
Definition: util.py:461