Skip to content

Commit 0f044e8

Browse files
committed
test: avoid direct block header modification in feature_block.py
This is a preparatory commit for removing the header hash caching in the CBlockHeader class. In order to not lose the old block hash, necessary for updating the internal state of the test (represented by `self.block_heights` and `self.blocks`), we should only modify it within the `update_block` method.
1 parent f3c791d commit 0f044e8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/functional/feature_block.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,7 @@ def run_test(self):
719719
# valid timestamp
720720
self.move_tip(53)
721721
b55 = self.next_block(55, spend=out[15])
722-
b55.nTime = b35.nTime
723-
self.update_block(55, [])
722+
self.update_block(55, [], nTime=b35.nTime)
724723
self.send_blocks([b55], True)
725724
self.save_spendable_output()
726725

@@ -1408,10 +1407,12 @@ def move_tip(self, number):
14081407
self.tip = self.blocks[number]
14091408

14101409
# adds transactions to the block and updates state
1411-
def update_block(self, block_number, new_transactions):
1410+
def update_block(self, block_number, new_transactions, *, nTime=None):
14121411
block = self.blocks[block_number]
14131412
self.add_transactions_to_block(block, new_transactions)
14141413
old_sha256 = block.sha256
1414+
if nTime is not None:
1415+
block.nTime = nTime
14151416
block.hashMerkleRoot = block.calc_merkle_root()
14161417
block.solve()
14171418
# Update the internal state just like in next_block

0 commit comments

Comments
 (0)