Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_dbcrash.py
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.debug("Syncing {} blocks with other nodes".format( | self.log.debug("Syncing {} blocks with other nodes".format( | ||||
len(block_hashes_to_sync))) | len(block_hashes_to_sync))) | ||||
# Syncing the blocks could cause nodes to crash, so the test begins | # Syncing the blocks could cause nodes to crash, so the test begins | ||||
# here. | # here. | ||||
self.sync_node3blocks(block_hashes_to_sync) | self.sync_node3blocks(block_hashes_to_sync) | ||||
starting_tip_height = self.nodes[3].getblockcount() | starting_tip_height = self.nodes[3].getblockcount() | ||||
# Set mock time to the last block time. This will allow us to increase | |||||
# the time at each loop so the block hash will always differ for the | |||||
# same block height, and avoid duplication. | |||||
# Note that the current time can be behind the block time due to the | |||||
# way the miner sets the block time. | |||||
tip = self.nodes[3].getbestblockhash() | |||||
block_time = self.nodes[3].getblockheader(tip)['time'] | |||||
self.nodes[3].setmocktime(block_time) | |||||
# Main test loop: | # Main test loop: | ||||
# each time through the loop, generate a bunch of transactions, | # each time through the loop, generate a bunch of transactions, | ||||
# and then either mine a single new block on the tip, or some-sized | # and then either mine a single new block on the tip, or some-sized | ||||
# reorg. | # reorg. | ||||
for i in range(40): | for i in range(40): | ||||
block_time += 10 | |||||
self.nodes[3].setmocktime(block_time) | |||||
self.log.info( | self.log.info( | ||||
"Iteration {}, generating 2500 transactions {}".format( | "Iteration {}, generating 2500 transactions {}".format( | ||||
i, self.restart_counts)) | i, self.restart_counts)) | ||||
# Generate a bunch of small-ish transactions | # Generate a bunch of small-ish transactions | ||||
self.generate_small_transactions(self.nodes[3], 2500, utxo_list) | self.generate_small_transactions(self.nodes[3], 2500, utxo_list) | ||||
# Pick a random block between current tip, and starting tip | # Pick a random block between current tip, and starting tip | ||||
current_height = self.nodes[3].getblockcount() | current_height = self.nodes[3].getblockcount() | ||||
random_height = random.randint(starting_tip_height, current_height) | random_height = random.randint(starting_tip_height, current_height) | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |