mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-27 23:39:46 +02:00
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.
Github-Pull: #33446
Rebased-From: bf7996cbc3
This commit is contained in:
@@ -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