mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
test: Add functional test for continuing a reindex
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
This commit is contained in:
parent
201c1a9282
commit
1b1c6dcca0
2 changed files with 22 additions and 2 deletions
|
@ -73,6 +73,25 @@ class ReindexTest(BitcoinTestFramework):
|
||||||
# All blocks should be accepted and processed.
|
# All blocks should be accepted and processed.
|
||||||
assert_equal(self.nodes[0].getblockcount(), 12)
|
assert_equal(self.nodes[0].getblockcount(), 12)
|
||||||
|
|
||||||
|
def continue_reindex_after_shutdown(self):
|
||||||
|
node = self.nodes[0]
|
||||||
|
self.generate(node, 1500)
|
||||||
|
|
||||||
|
# Restart node with reindex and stop reindex as soon as it starts reindexing
|
||||||
|
self.log.info("Restarting node while reindexing..")
|
||||||
|
node.stop_node()
|
||||||
|
with node.busy_wait_for_debug_log([b'initload thread start']):
|
||||||
|
node.start(['-blockfilterindex', '-reindex'])
|
||||||
|
node.wait_for_rpc_connection(wait_for_import=False)
|
||||||
|
node.stop_node()
|
||||||
|
|
||||||
|
# Start node without the reindex flag and verify it does not wipe the indexes data again
|
||||||
|
db_path = node.chain_path / 'indexes' / 'blockfilter' / 'basic' / 'db'
|
||||||
|
with node.assert_debug_log(expected_msgs=[f'Opening LevelDB in {db_path}'], unexpected_msgs=[f'Wiping LevelDB in {db_path}']):
|
||||||
|
node.start(['-blockfilterindex'])
|
||||||
|
node.wait_for_rpc_connection(wait_for_import=False)
|
||||||
|
node.stop_node()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.reindex(False)
|
self.reindex(False)
|
||||||
self.reindex(True)
|
self.reindex(True)
|
||||||
|
@ -80,6 +99,7 @@ class ReindexTest(BitcoinTestFramework):
|
||||||
self.reindex(True)
|
self.reindex(True)
|
||||||
|
|
||||||
self.out_of_order()
|
self.out_of_order()
|
||||||
|
self.continue_reindex_after_shutdown()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -241,7 +241,7 @@ class TestNode():
|
||||||
if self.start_perf:
|
if self.start_perf:
|
||||||
self._start_perf()
|
self._start_perf()
|
||||||
|
|
||||||
def wait_for_rpc_connection(self):
|
def wait_for_rpc_connection(self, *, wait_for_import=True):
|
||||||
"""Sets up an RPC connection to the bitcoind process. Returns False if unable to connect."""
|
"""Sets up an RPC connection to the bitcoind process. Returns False if unable to connect."""
|
||||||
# Poll at a rate of four times per second
|
# Poll at a rate of four times per second
|
||||||
poll_per_s = 4
|
poll_per_s = 4
|
||||||
|
@ -263,7 +263,7 @@ class TestNode():
|
||||||
)
|
)
|
||||||
rpc.getblockcount()
|
rpc.getblockcount()
|
||||||
# If the call to getblockcount() succeeds then the RPC connection is up
|
# If the call to getblockcount() succeeds then the RPC connection is up
|
||||||
if self.version_is_at_least(190000):
|
if self.version_is_at_least(190000) and wait_for_import:
|
||||||
# getmempoolinfo.loaded is available since commit
|
# getmempoolinfo.loaded is available since commit
|
||||||
# bb8ae2c (version 0.19.0)
|
# bb8ae2c (version 0.19.0)
|
||||||
self.wait_until(lambda: rpc.getmempoolinfo()['loaded'])
|
self.wait_until(lambda: rpc.getmempoolinfo()['loaded'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue