mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 07:09:29 +02:00
test: rename CBlockHeader .hash -> .hash_hex for consistency
Note that we unfortunately can't use a scripted diff here, as the `.hash` symbol is also used for other instances (e.g. CInv).
This commit is contained in:
@@ -445,25 +445,25 @@ class MiningTest(BitcoinTestFramework):
|
||||
def chain_tip(b_hash, *, status='headers-only', branchlen=1):
|
||||
return {'hash': b_hash, 'height': 202, 'branchlen': branchlen, 'status': status}
|
||||
|
||||
assert chain_tip(block.hash) not in node.getchaintips()
|
||||
assert chain_tip(block.hash_hex) not in node.getchaintips()
|
||||
node.submitheader(hexdata=block.serialize().hex())
|
||||
assert chain_tip(block.hash) in node.getchaintips()
|
||||
assert chain_tip(block.hash_hex) in node.getchaintips()
|
||||
node.submitheader(hexdata=CBlockHeader(block).serialize().hex()) # Noop
|
||||
assert chain_tip(block.hash) in node.getchaintips()
|
||||
assert chain_tip(block.hash_hex) in node.getchaintips()
|
||||
|
||||
bad_block_root = copy.deepcopy(block)
|
||||
bad_block_root.hashMerkleRoot += 2
|
||||
bad_block_root.solve()
|
||||
assert chain_tip(bad_block_root.hash) not in node.getchaintips()
|
||||
assert chain_tip(bad_block_root.hash_hex) not in node.getchaintips()
|
||||
node.submitheader(hexdata=CBlockHeader(bad_block_root).serialize().hex())
|
||||
assert chain_tip(bad_block_root.hash) in node.getchaintips()
|
||||
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
|
||||
# Should still reject invalid blocks, even if we have the header:
|
||||
assert_equal(node.submitblock(hexdata=bad_block_root.serialize().hex()), 'bad-txnmrklroot')
|
||||
assert_equal(node.submitblock(hexdata=bad_block_root.serialize().hex()), 'bad-txnmrklroot')
|
||||
assert chain_tip(bad_block_root.hash) in node.getchaintips()
|
||||
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
|
||||
# We know the header for this invalid block, so should just return early without error:
|
||||
node.submitheader(hexdata=CBlockHeader(bad_block_root).serialize().hex())
|
||||
assert chain_tip(bad_block_root.hash) in node.getchaintips()
|
||||
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
|
||||
|
||||
bad_block_lock = copy.deepcopy(block)
|
||||
bad_block_lock.vtx[0].nLockTime = 2**32 - 1
|
||||
@@ -488,7 +488,7 @@ class MiningTest(BitcoinTestFramework):
|
||||
peer.wait_for_getheaders(timeout=5, block_hash=block.hashPrevBlock)
|
||||
peer.send_blocks_and_test(blocks=[block], node=node)
|
||||
# Must be active now:
|
||||
assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips()
|
||||
assert chain_tip(block.hash_hex, status='active', branchlen=0) in node.getchaintips()
|
||||
|
||||
# Building a few blocks should give the same results
|
||||
self.generatetoaddress(node, 10, node.get_deterministic_priv_key().address)
|
||||
|
||||
Reference in New Issue
Block a user