2525 assert_equal ,
2626 assert_greater_than ,
2727 assert_raises_rpc_error ,
28+ try_rpc ,
2829)
2930
3031# Rescans start at the earliest block up to 2 hours before a key timestamp, so
@@ -479,8 +480,12 @@ def run_test(self):
479480 self .log .info ("Test invalid pruning command line options" )
480481 self .test_invalid_command_line_options ()
481482
483+ self .log .info ("Test scanblocks can not return pruned data" )
482484 self .test_scanblocks_pruned ()
483485
486+ self .log .info ("Test pruneheight reflects the presence of block and undo data" )
487+ self .test_pruneheight_undo_presence ()
488+
484489 self .log .info ("Done" )
485490
486491 def test_scanblocks_pruned (self ):
@@ -494,5 +499,18 @@ def test_scanblocks_pruned(self):
494499 assert_raises_rpc_error (- 1 , "Block not available (pruned data)" , node .scanblocks ,
495500 "start" , [{"desc" : f"raw({ false_positive_spk .hex ()} )" }], 0 , 0 , "basic" , {"filter_false_positives" : True })
496501
502+ def test_pruneheight_undo_presence (self ):
503+ node = self .nodes [2 ]
504+ pruneheight = node .getblockchaininfo ()["pruneheight" ]
505+ fetch_block = node .getblockhash (pruneheight - 1 )
506+
507+ self .connect_nodes (1 , 2 )
508+ peers = node .getpeerinfo ()
509+ node .getblockfrompeer (fetch_block , peers [0 ]["id" ])
510+ self .wait_until (lambda : not try_rpc (- 1 , "Block not available (pruned data)" , node .getblock , fetch_block ), timeout = 5 )
511+
512+ new_pruneheight = node .getblockchaininfo ()["pruneheight" ]
513+ assert_equal (pruneheight , new_pruneheight )
514+
497515if __name__ == '__main__' :
498516 PruneTest ().main ()
0 commit comments