Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_pruning.py
Show First 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | def manual_test(self, node_number, use_timestamp): | ||||
def has_block(index): | def has_block(index): | ||||
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index))) | return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index))) | ||||
# should not prune because chain tip of node 3 (995) < PruneAfterHeight | # should not prune because chain tip of node 3 (995) < PruneAfterHeight | ||||
# (1000) | # (1000) | ||||
assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
-1, "Blockchain is too short for pruning", node.pruneblockchain, height(500)) | -1, "Blockchain is too short for pruning", node.pruneblockchain, height(500)) | ||||
# Save block transaction count before pruning, assert value | |||||
block1_details = node.getblock(node.getblockhash(1)) | |||||
assert_equal(block1_details["nTx"], len(block1_details["tx"])) | |||||
# mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight) | # mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight) | ||||
node.generate(6) | node.generate(6) | ||||
assert_equal(node.getblockchaininfo()["blocks"], 1001) | assert_equal(node.getblockchaininfo()["blocks"], 1001) | ||||
# Pruned block should still know the number of transactions | |||||
assert_equal(node.getblockheader(node.getblockhash(1)) | |||||
["nTx"], block1_details["nTx"]) | |||||
# negative heights should raise an exception | # negative heights should raise an exception | ||||
assert_raises_rpc_error(-8, "Negative", node.pruneblockchain, -10) | assert_raises_rpc_error(-8, "Negative", node.pruneblockchain, -10) | ||||
# height=100 too low to prune first block file so this is a no-op | # height=100 too low to prune first block file so this is a no-op | ||||
prune(100) | prune(100) | ||||
assert has_block( | assert has_block( | ||||
0), "blk00000.dat is missing when should still be there" | 0), "blk00000.dat is missing when should still be there" | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |