You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feature_reindex.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2014-2017 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.
  6. - Start a single node and generate 3 blocks.
  7. - Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.
  8. - Stop the node and restart it with -reindex-chainstate. Verify that the node has reindexed up to block 3.
  9. """
  10. from test_framework.test_framework import BitcoinTestFramework
  11. from test_framework.util import wait_until
  12. class ReindexTest(BitcoinTestFramework):
  13. def set_test_params(self):
  14. self.setup_clean_chain = True
  15. self.num_nodes = 1
  16. def reindex(self, justchainstate=False):
  17. self.nodes[0].generate(3)
  18. blockcount = self.nodes[0].getblockcount()
  19. self.stop_nodes()
  20. extra_args = [["-reindex-chainstate" if justchainstate else "-reindex", "-checkblockindex=1"]]
  21. self.start_nodes(extra_args)
  22. wait_until(lambda: self.nodes[0].getblockcount() == blockcount)
  23. self.log.info("Success")
  24. def run_test(self):
  25. self.reindex(False)
  26. self.reindex(True)
  27. self.reindex(False)
  28. self.reindex(True)
  29. if __name__ == '__main__':
  30. ReindexTest().main()