6
6
7
7
Test the following RPCs:
8
8
- getblockchaininfo
9
+ - getchaintxstats
9
10
- gettxoutsetinfo
10
- - getdifficulty
11
- - getbestblockhash
12
- - getblockhash
13
11
- getblockheader
14
- - getchaintxstats
12
+ - getdifficulty
15
13
- getnetworkhashps
14
+ - waitforblockheight
15
+ - getblock
16
+ - getblockhash
17
+ - getbestblockhash
16
18
- verifychain
17
19
18
20
Tests correspond to code in rpc/blockchain.cpp.
@@ -246,7 +248,7 @@ def _test_gettxoutsetinfo(self):
246
248
assert_equal (len (res ['bestblock' ]), 64 )
247
249
assert_equal (len (res ['hash_serialized_2' ]), 64 )
248
250
249
- self .log .info ("Test that gettxoutsetinfo() works for blockchain with just the genesis block" )
251
+ self .log .info ("Test gettxoutsetinfo works for blockchain with just the genesis block" )
250
252
b1hash = node .getblockhash (1 )
251
253
node .invalidateblock (b1hash )
252
254
@@ -259,7 +261,7 @@ def _test_gettxoutsetinfo(self):
259
261
assert_equal (res2 ['bestblock' ], node .getblockhash (0 ))
260
262
assert_equal (len (res2 ['hash_serialized_2' ]), 64 )
261
263
262
- self .log .info ("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block" )
264
+ self .log .info ("Test gettxoutsetinfo returns the same result after invalidate/reconsider block" )
263
265
node .reconsiderblock (b1hash )
264
266
265
267
res3 = node .gettxoutsetinfo ()
@@ -268,7 +270,7 @@ def _test_gettxoutsetinfo(self):
268
270
del res ['disk_size' ], res3 ['disk_size' ]
269
271
assert_equal (res , res3 )
270
272
271
- self .log .info ("Test hash_type option for gettxoutsetinfo() " )
273
+ self .log .info ("Test gettxoutsetinfo hash_type option" )
272
274
# Adding hash_type 'hash_serialized_2', which is the default, should
273
275
# not change the result.
274
276
res4 = node .gettxoutsetinfo (hash_type = 'hash_serialized_2' )
@@ -292,6 +294,7 @@ def _test_gettxoutsetinfo(self):
292
294
assert_raises_rpc_error (- 8 , "foohash is not a valid hash_type" , node .gettxoutsetinfo , "foohash" )
293
295
294
296
def _test_getblockheader (self ):
297
+ self .log .info ("Test getblockheader" )
295
298
node = self .nodes [0 ]
296
299
297
300
assert_raises_rpc_error (- 8 , "hash must be of length 64 (not 8, for 'nonsense')" , node .getblockheader , "nonsense" )
@@ -331,17 +334,20 @@ def _test_getblockheader(self):
331
334
assert 'nextblockhash' not in node .getblockheader (node .getbestblockhash ())
332
335
333
336
def _test_getdifficulty (self ):
337
+ self .log .info ("Test getdifficulty" )
334
338
difficulty = self .nodes [0 ].getdifficulty ()
335
339
# 1 hash in 2 should be valid, so difficulty should be 1/2**31
336
340
# binary => decimal => binary math is why we do this check
337
341
assert abs (difficulty * 2 ** 31 - 1 ) < 0.0001
338
342
339
343
def _test_getnetworkhashps (self ):
344
+ self .log .info ("Test getnetworkhashps" )
340
345
hashes_per_second = self .nodes [0 ].getnetworkhashps ()
341
346
# This should be 2 hashes every 10 minutes or 1/300
342
347
assert abs (hashes_per_second * 300 - 1 ) < 0.0001
343
348
344
349
def _test_stopatheight (self ):
350
+ self .log .info ("Test stopping at height" )
345
351
assert_equal (self .nodes [0 ].getblockcount (), HEIGHT )
346
352
self .nodes [0 ].generatetoaddress (6 , ADDRESS_BCRT1_P2WSH_OP_TRUE )
347
353
assert_equal (self .nodes [0 ].getblockcount (), HEIGHT + 6 )
@@ -406,20 +412,20 @@ def _test_getblock(self):
406
412
miniwallet .send_self_transfer (fee_rate = fee_per_kb , from_node = node )
407
413
blockhash = node .generate (1 )[0 ]
408
414
409
- self .log .info ("Test that getblock with verbosity 1 doesn't include fee" )
415
+ self .log .info ("Test getblock with verbosity 1 doesn't include fee" )
410
416
block = node .getblock (blockhash , 1 )
411
417
assert 'fee' not in block ['tx' ][1 ]
412
418
413
- self .log .info ('Test that getblock with verbosity 2 includes expected fee' )
419
+ self .log .info ('Test getblock with verbosity 2 includes expected fee' )
414
420
block = node .getblock (blockhash , 2 )
415
421
tx = block ['tx' ][1 ]
416
422
assert 'fee' in tx
417
423
assert_equal (tx ['fee' ], tx ['vsize' ] * fee_per_byte )
418
424
419
- self .log .info ("Test that getblock with verbosity 2 still works with pruned Undo data" )
425
+ self .log .info ("Test getblock with verbosity 2 still works with pruned Undo data" )
420
426
datadir = get_datadir_path (self .options .tmpdir , 0 )
421
427
422
- self .log .info ("Test that getblock with invalid verbosity type returns proper error message" )
428
+ self .log .info ("Test getblock with invalid verbosity type returns proper error message" )
423
429
assert_raises_rpc_error (- 1 , "JSON value is not an integer as expected" , node .getblock , blockhash , "2" )
424
430
425
431
def move_block_file (old , new ):
0 commit comments