rpc: fix getblock(header) returns target for tip
A target field was added to the getblock and getblockheader RPC calls in bitcoin#31583, but it mistakingly always used the tip value. Because regtest does not have difficulty adjustment, a test is added for mainnet instead.
This commit is contained in:
2 files changed
+13
-1
No files matched your search
@@ -109,5 +109,17 @@ class MiningMainnetTest(BitcoinTestFramework):
|
||||
height = 2016
|
||||
prev_hash = self.mine(height, prev_hash, blocks, node)
|
||||
assert_equal(node.getblockcount(), height)
|
||||
|
||||
mining_info = node.getmininginfo()
|
||||
assert_equal(mining_info['difficulty'], 4)
|
||||
|
||||
self.log.info("getblock RPC should show historical target")
|
||||
block_info = node.getblock(node.getblockhash(1))
|
||||
|
||||
assert_equal(block_info['difficulty'], 1)
|
||||
assert_equal(block_info['bits'], nbits_str(DIFF_1_N_BITS))
|
||||
assert_equal(block_info['target'], target_str(DIFF_1_TARGET))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
MiningMainnetTest(__file__).main()
|
||||
Reference in new issue
Block a user