Skip to content

Commit 2118301

Browse files
committed
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).
1 parent 23be0ec commit 2118301

22 files changed

+84
-84
lines changed

contrib/signet/miner

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,15 @@ def do_generate(args):
481481
# report
482482
bstr = "block" if gen.is_mine else "backup block"
483483

484-
next_delta = gen.next_block_delta(block.nBits, block.hash)
484+
next_delta = gen.next_block_delta(block.nBits, block.hash_hex)
485485
next_delta += block.nTime - time.time()
486-
next_is_mine = gen.next_block_is_mine(block.hash)
486+
next_is_mine = gen.next_block_is_mine(block.hash_hex)
487487

488-
logging.debug("Block hash %s payout to %s", block.hash, reward_addr)
488+
logging.debug("Block hash %s payout to %s", block.hash_hex, reward_addr)
489489
logging.info("Mined %s at height %d; next in %s (%s)", bstr, tmpl["height"], seconds_to_hms(next_delta), ("mine" if next_is_mine else "backup"))
490490
if r != "":
491-
logging.warning("submitblock returned %s for height %d hash %s", r, tmpl["height"], block.hash)
492-
lastheader = block.hash
491+
logging.warning("submitblock returned %s for height %d hash %s", r, tmpl["height"], block.hash_hex)
492+
lastheader = block.hash_hex
493493

494494
def do_calibrate(args):
495495
if args.nbits is not None and args.seconds is not None:

test/functional/feature_assumevalid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def run_test(self):
138138
height += 1
139139

140140
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
141-
self.start_node(1, extra_args=["-assumevalid=" + block102.hash])
142-
self.start_node(2, extra_args=["-assumevalid=" + block102.hash])
141+
self.start_node(1, extra_args=["-assumevalid=" + block102.hash_hex])
142+
self.start_node(2, extra_args=["-assumevalid=" + block102.hash_hex])
143143

144144
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
145145
p2p0.send_header_for_blocks(self.blocks[0:2000])

test/functional/feature_bip68_sequence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def test_bip68_not_consensus(self):
383383
block.solve()
384384

385385
assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
386-
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
386+
assert_equal(self.nodes[0].getbestblockhash(), block.hash_hex)
387387

388388
def activateCSV(self):
389389
# activation should happen at block height 432 (3 periods)

test/functional/feature_block.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def run_test(self):
280280
self.send_blocks([b12, b13, b14], success=False, reject_reason='bad-cb-amount', reconnect=True)
281281

282282
# New tip should be b13.
283-
assert_equal(node.getbestblockhash(), b13.hash)
283+
assert_equal(node.getbestblockhash(), b13.hash_hex)
284284

285285
# Add a block with MAX_BLOCK_SIGOPS and one with one more sigop
286286
# genesis -> b1 (0) -> b2 (1) -> b5 (2) -> b6 (3)
@@ -734,7 +734,7 @@ def run_test(self):
734734
self.block_heights[b48.hash_int] = self.block_heights[b44.hash_int] + 1 # b48 is a parent of b44
735735
b48p = self.next_block("48p")
736736
self.send_blocks([b48, b48p], success=True) # Reorg to the longer chain
737-
node.invalidateblock(b48p.hash) # mark b48p as invalid
737+
node.invalidateblock(b48p.hash_hex) # mark b48p as invalid
738738
node.setmocktime(0)
739739

740740
# Test Merkle tree malleability
@@ -778,7 +778,7 @@ def run_test(self):
778778
self.blocks[56] = b56
779779
assert_equal(len(b56.vtx), 3)
780780
b56 = self.update_block(56, [tx1])
781-
assert_equal(b56.hash, b57.hash)
781+
assert_equal(b56.hash_hex, b57.hash_hex)
782782
self.send_blocks([b56], success=False, reject_reason='bad-txns-duplicate', reconnect=True)
783783

784784
# b57p2 - a good block with 6 tx'es, don't submit until end
@@ -796,7 +796,7 @@ def run_test(self):
796796
self.move_tip(55)
797797
b56p2 = copy.deepcopy(b57p2)
798798
self.blocks["b56p2"] = b56p2
799-
assert_equal(b56p2.hash, b57p2.hash)
799+
assert_equal(b56p2.hash_hex, b57p2.hash_hex)
800800
assert_equal(len(b56p2.vtx), 6)
801801
b56p2 = self.update_block("b56p2", [tx3, tx4])
802802
self.send_blocks([b56p2], success=False, reject_reason='bad-txns-duplicate', reconnect=True)
@@ -954,7 +954,7 @@ def run_test(self):
954954
self.move_tip('dup_2')
955955
b64 = CBlock(b64a)
956956
b64.vtx = copy.deepcopy(b64a.vtx)
957-
assert_equal(b64.hash, b64a.hash)
957+
assert_equal(b64.hash_hex, b64a.hash_hex)
958958
assert_equal(b64.get_weight(), MAX_BLOCK_WEIGHT)
959959
self.blocks[64] = b64
960960
b64 = self.update_block(64, [])

test/functional/feature_cltv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ def run_test(self):
127127
self.test_cltv_info(is_active=False) # Not active as of current tip and next block does not need to obey rules
128128
peer.send_and_ping(msg_block(block))
129129
self.test_cltv_info(is_active=True) # Not active as of current tip, but next block must obey rules
130-
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
130+
assert_equal(self.nodes[0].getbestblockhash(), block.hash_hex)
131131

132132
self.log.info("Test that blocks must now be at least version 4")
133133
tip = block.hash_int
134134
block_time += 1
135135
block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time, version=3)
136136
block.solve()
137137

138-
with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash}, bad-version(0x00000003)']):
138+
with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash_hex}, bad-version(0x00000003)']):
139139
peer.send_and_ping(msg_block(block))
140140
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
141141
peer.sync_with_ping()

test/functional/feature_dersig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ def run_test(self):
9292
peer.send_and_ping(msg_block(block))
9393
assert_equal(self.nodes[0].getblockcount(), DERSIG_HEIGHT - 1)
9494
self.test_dersig_info(is_active=True) # Not active as of current tip, but next block must obey rules
95-
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
95+
assert_equal(self.nodes[0].getbestblockhash(), block.hash_hex)
9696

9797
self.log.info("Test that blocks must now be at least version 3")
9898
tip = block.hash_int
9999
block_time += 1
100100
block = create_block(tip, create_coinbase(DERSIG_HEIGHT), block_time, version=2)
101101
block.solve()
102102

103-
with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash}, bad-version(0x00000002)']):
103+
with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash_hex}, bad-version(0x00000002)']):
104104
peer.send_and_ping(msg_block(block))
105105
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
106106
peer.sync_with_ping()

test/functional/feature_nulldummy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def block_submit(self, node, txs, *, with_witness=False, accept):
143143
block.solve()
144144
assert_equal(None if accept else NULLDUMMY_ERROR, node.submitblock(block.serialize().hex()))
145145
if accept:
146-
assert_equal(node.getbestblockhash(), block.hash)
147-
self.lastblockhash = block.hash
146+
assert_equal(node.getbestblockhash(), block.hash_hex)
147+
self.lastblockhash = block.hash_hex
148148
self.lastblocktime += 1
149149
self.lastblockheight += 1
150150
else:

test/functional/feature_taproot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,9 +1341,9 @@ def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_w
13411341
if err_msg is not None:
13421342
assert block_response is not None and err_msg in block_response, "Missing error message '%s' from block response '%s': %s" % (err_msg, "(None)" if block_response is None else block_response, msg)
13431343
if accept:
1344-
assert node.getbestblockhash() == block.hash, "Failed to accept: %s (response: %s)" % (msg, block_response)
1344+
assert node.getbestblockhash() == block.hash_hex, "Failed to accept: %s (response: %s)" % (msg, block_response)
13451345
self.tip = block.hash_int
1346-
self.lastblockhash = block.hash
1346+
self.lastblockhash = block.hash_hex
13471347
self.lastblocktime += 1
13481348
self.lastblockheight += 1
13491349
else:

test/functional/mining_basic.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,25 +445,25 @@ def run_test(self):
445445
def chain_tip(b_hash, *, status='headers-only', branchlen=1):
446446
return {'hash': b_hash, 'height': 202, 'branchlen': branchlen, 'status': status}
447447

448-
assert chain_tip(block.hash) not in node.getchaintips()
448+
assert chain_tip(block.hash_hex) not in node.getchaintips()
449449
node.submitheader(hexdata=block.serialize().hex())
450-
assert chain_tip(block.hash) in node.getchaintips()
450+
assert chain_tip(block.hash_hex) in node.getchaintips()
451451
node.submitheader(hexdata=CBlockHeader(block).serialize().hex()) # Noop
452-
assert chain_tip(block.hash) in node.getchaintips()
452+
assert chain_tip(block.hash_hex) in node.getchaintips()
453453

454454
bad_block_root = copy.deepcopy(block)
455455
bad_block_root.hashMerkleRoot += 2
456456
bad_block_root.solve()
457-
assert chain_tip(bad_block_root.hash) not in node.getchaintips()
457+
assert chain_tip(bad_block_root.hash_hex) not in node.getchaintips()
458458
node.submitheader(hexdata=CBlockHeader(bad_block_root).serialize().hex())
459-
assert chain_tip(bad_block_root.hash) in node.getchaintips()
459+
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
460460
# Should still reject invalid blocks, even if we have the header:
461461
assert_equal(node.submitblock(hexdata=bad_block_root.serialize().hex()), 'bad-txnmrklroot')
462462
assert_equal(node.submitblock(hexdata=bad_block_root.serialize().hex()), 'bad-txnmrklroot')
463-
assert chain_tip(bad_block_root.hash) in node.getchaintips()
463+
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
464464
# We know the header for this invalid block, so should just return early without error:
465465
node.submitheader(hexdata=CBlockHeader(bad_block_root).serialize().hex())
466-
assert chain_tip(bad_block_root.hash) in node.getchaintips()
466+
assert chain_tip(bad_block_root.hash_hex) in node.getchaintips()
467467

468468
bad_block_lock = copy.deepcopy(block)
469469
bad_block_lock.vtx[0].nLockTime = 2**32 - 1
@@ -488,7 +488,7 @@ def chain_tip(b_hash, *, status='headers-only', branchlen=1):
488488
peer.wait_for_getheaders(timeout=5, block_hash=block.hashPrevBlock)
489489
peer.send_blocks_and_test(blocks=[block], node=node)
490490
# Must be active now:
491-
assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips()
491+
assert chain_tip(block.hash_hex, status='active', branchlen=0) in node.getchaintips()
492492

493493
# Building a few blocks should give the same results
494494
self.generatetoaddress(node, 10, node.get_deterministic_priv_key().address)

test/functional/mining_mainnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def mine(self, height, prev_hash, blocks, node, fees=0):
7070
self.log.debug(block_hex)
7171
assert_equal(node.submitblock(block_hex), None)
7272
prev_hash = node.getbestblockhash()
73-
assert_equal(prev_hash, block.hash)
73+
assert_equal(prev_hash, block.hash_hex)
7474
return prev_hash
7575

7676

0 commit comments

Comments
 (0)