mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 05:57:59 +01:00
rpc: Make pruneheight also reflect undo data presence
This commit is contained in:
@@ -25,6 +25,7 @@ from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than,
|
||||
assert_raises_rpc_error,
|
||||
try_rpc,
|
||||
)
|
||||
|
||||
# Rescans start at the earliest block up to 2 hours before a key timestamp, so
|
||||
@@ -479,8 +480,12 @@ class PruneTest(BitcoinTestFramework):
|
||||
self.log.info("Test invalid pruning command line options")
|
||||
self.test_invalid_command_line_options()
|
||||
|
||||
self.log.info("Test scanblocks can not return pruned data")
|
||||
self.test_scanblocks_pruned()
|
||||
|
||||
self.log.info("Test pruneheight reflects the presence of block and undo data")
|
||||
self.test_pruneheight_undo_presence()
|
||||
|
||||
self.log.info("Done")
|
||||
|
||||
def test_scanblocks_pruned(self):
|
||||
@@ -494,5 +499,18 @@ class PruneTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-1, "Block not available (pruned data)", node.scanblocks,
|
||||
"start", [{"desc": f"raw({false_positive_spk.hex()})"}], 0, 0, "basic", {"filter_false_positives": True})
|
||||
|
||||
def test_pruneheight_undo_presence(self):
|
||||
node = self.nodes[2]
|
||||
pruneheight = node.getblockchaininfo()["pruneheight"]
|
||||
fetch_block = node.getblockhash(pruneheight - 1)
|
||||
|
||||
self.connect_nodes(1, 2)
|
||||
peers = node.getpeerinfo()
|
||||
node.getblockfrompeer(fetch_block, peers[0]["id"])
|
||||
self.wait_until(lambda: not try_rpc(-1, "Block not available (pruned data)", node.getblock, fetch_block), timeout=5)
|
||||
|
||||
new_pruneheight = node.getblockchaininfo()["pruneheight"]
|
||||
assert_equal(pruneheight, new_pruneheight)
|
||||
|
||||
if __name__ == '__main__':
|
||||
PruneTest().main()
|
||||
|
||||
Reference in New Issue
Block a user