@@ -114,7 +114,7 @@ def run_test(self):
114
114
assert_equal (stats [self .max_stat_pos ]['height' ], self .start_height + self .max_stat_pos )
115
115
116
116
for i in range (self .max_stat_pos + 1 ):
117
- self .log .info ('Checking block %d\n ' % (i ))
117
+ self .log .info ('Checking block %d' % (i ))
118
118
assert_equal (stats [i ], self .expected_stats [i ])
119
119
120
120
# Check selecting block by hash too
@@ -182,5 +182,16 @@ def run_test(self):
182
182
assert_equal (tip_stats ["utxo_increase_actual" ], 4 )
183
183
assert_equal (tip_stats ["utxo_size_inc_actual" ], 300 )
184
184
185
+ self .log .info ("Test when only header is known" )
186
+ block = self .generateblock (self .nodes [0 ], output = "raw(55)" , transactions = [], submit = False )
187
+ self .nodes [0 ].submitheader (block ["hex" ])
188
+ assert_raises_rpc_error (- 1 , "Block not available (not fully downloaded)" , lambda : self .nodes [0 ].getblockstats (block ['hash' ]))
189
+
190
+ self .log .info ('Test when block is missing' )
191
+ (self .nodes [0 ].blocks_path / 'blk00000.dat' ).rename (self .nodes [0 ].blocks_path / 'blk00000.dat.backup' )
192
+ assert_raises_rpc_error (- 1 , 'Block not found on disk' , self .nodes [0 ].getblockstats , hash_or_height = 1 )
193
+ (self .nodes [0 ].blocks_path / 'blk00000.dat.backup' ).rename (self .nodes [0 ].blocks_path / 'blk00000.dat' )
194
+
195
+
185
196
if __name__ == '__main__' :
186
197
GetblockstatsTest (__file__ ).main ()
0 commit comments