25
25
assert_equal ,
26
26
assert_greater_than ,
27
27
assert_raises_rpc_error ,
28
+ try_rpc ,
28
29
)
29
30
30
31
# Rescans start at the earliest block up to 2 hours before a key timestamp, so
@@ -479,8 +480,12 @@ def run_test(self):
479
480
self .log .info ("Test invalid pruning command line options" )
480
481
self .test_invalid_command_line_options ()
481
482
483
+ self .log .info ("Test scanblocks can not return pruned data" )
482
484
self .test_scanblocks_pruned ()
483
485
486
+ self .log .info ("Test pruneheight reflects the presence of block and undo data" )
487
+ self .test_pruneheight_undo_presence ()
488
+
484
489
self .log .info ("Done" )
485
490
486
491
def test_scanblocks_pruned (self ):
@@ -494,5 +499,18 @@ def test_scanblocks_pruned(self):
494
499
assert_raises_rpc_error (- 1 , "Block not available (pruned data)" , node .scanblocks ,
495
500
"start" , [{"desc" : f"raw({ false_positive_spk .hex ()} )" }], 0 , 0 , "basic" , {"filter_false_positives" : True })
496
501
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
+
497
515
if __name__ == '__main__' :
498
516
PruneTest ().main ()
0 commit comments