Skip to content

Commit ef5e930

Browse files
committed
test: update logging and docstring in rpc_blockchain.py
1 parent d548dc7 commit ef5e930

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/functional/rpc_blockchain.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
77
Test the following RPCs:
88
- getblockchaininfo
9+
- getchaintxstats
910
- gettxoutsetinfo
10-
- getdifficulty
11-
- getbestblockhash
12-
- getblockhash
1311
- getblockheader
14-
- getchaintxstats
12+
- getdifficulty
1513
- getnetworkhashps
14+
- waitforblockheight
15+
- getblock
16+
- getblockhash
17+
- getbestblockhash
1618
- verifychain
1719
1820
Tests correspond to code in rpc/blockchain.cpp.
@@ -246,7 +248,7 @@ def _test_gettxoutsetinfo(self):
246248
assert_equal(len(res['bestblock']), 64)
247249
assert_equal(len(res['hash_serialized_2']), 64)
248250

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")
250252
b1hash = node.getblockhash(1)
251253
node.invalidateblock(b1hash)
252254

@@ -259,7 +261,7 @@ def _test_gettxoutsetinfo(self):
259261
assert_equal(res2['bestblock'], node.getblockhash(0))
260262
assert_equal(len(res2['hash_serialized_2']), 64)
261263

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")
263265
node.reconsiderblock(b1hash)
264266

265267
res3 = node.gettxoutsetinfo()
@@ -268,7 +270,7 @@ def _test_gettxoutsetinfo(self):
268270
del res['disk_size'], res3['disk_size']
269271
assert_equal(res, res3)
270272

271-
self.log.info("Test hash_type option for gettxoutsetinfo()")
273+
self.log.info("Test gettxoutsetinfo hash_type option")
272274
# Adding hash_type 'hash_serialized_2', which is the default, should
273275
# not change the result.
274276
res4 = node.gettxoutsetinfo(hash_type='hash_serialized_2')
@@ -292,6 +294,7 @@ def _test_gettxoutsetinfo(self):
292294
assert_raises_rpc_error(-8, "foohash is not a valid hash_type", node.gettxoutsetinfo, "foohash")
293295

294296
def _test_getblockheader(self):
297+
self.log.info("Test getblockheader")
295298
node = self.nodes[0]
296299

297300
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):
331334
assert 'nextblockhash' not in node.getblockheader(node.getbestblockhash())
332335

333336
def _test_getdifficulty(self):
337+
self.log.info("Test getdifficulty")
334338
difficulty = self.nodes[0].getdifficulty()
335339
# 1 hash in 2 should be valid, so difficulty should be 1/2**31
336340
# binary => decimal => binary math is why we do this check
337341
assert abs(difficulty * 2**31 - 1) < 0.0001
338342

339343
def _test_getnetworkhashps(self):
344+
self.log.info("Test getnetworkhashps")
340345
hashes_per_second = self.nodes[0].getnetworkhashps()
341346
# This should be 2 hashes every 10 minutes or 1/300
342347
assert abs(hashes_per_second * 300 - 1) < 0.0001
343348

344349
def _test_stopatheight(self):
350+
self.log.info("Test stopping at height")
345351
assert_equal(self.nodes[0].getblockcount(), HEIGHT)
346352
self.nodes[0].generatetoaddress(6, ADDRESS_BCRT1_P2WSH_OP_TRUE)
347353
assert_equal(self.nodes[0].getblockcount(), HEIGHT + 6)
@@ -406,20 +412,20 @@ def _test_getblock(self):
406412
miniwallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
407413
blockhash = node.generate(1)[0]
408414

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")
410416
block = node.getblock(blockhash, 1)
411417
assert 'fee' not in block['tx'][1]
412418

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')
414420
block = node.getblock(blockhash, 2)
415421
tx = block['tx'][1]
416422
assert 'fee' in tx
417423
assert_equal(tx['fee'], tx['vsize'] * fee_per_byte)
418424

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")
420426
datadir = get_datadir_path(self.options.tmpdir, 0)
421427

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")
423429
assert_raises_rpc_error(-1, "JSON value is not an integer as expected", node.getblock, blockhash, "2")
424430

425431
def move_block_file(old, new):

0 commit comments

Comments
 (0)