From 0f044e82bd5fe116a5e3560346ac78da9c9a6e54 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sat, 14 Jun 2025 19:15:49 +0200 Subject: [PATCH] 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. --- test/functional/feature_block.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index 0e2e685247f..34a69d4fe8e 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -719,8 +719,7 @@ class FullBlockTest(BitcoinTestFramework): # valid timestamp self.move_tip(53) b55 = self.next_block(55, spend=out[15]) - b55.nTime = b35.nTime - self.update_block(55, []) + self.update_block(55, [], nTime=b35.nTime) self.send_blocks([b55], True) self.save_spendable_output() @@ -1408,10 +1407,12 @@ class FullBlockTest(BitcoinTestFramework): self.tip = self.blocks[number] # adds transactions to the block and updates state - def update_block(self, block_number, new_transactions): + def update_block(self, block_number, new_transactions, *, nTime=None): block = self.blocks[block_number] self.add_transactions_to_block(block, new_transactions) old_sha256 = block.sha256 + if nTime is not None: + block.nTime = nTime block.hashMerkleRoot = block.calc_merkle_root() block.solve() # Update the internal state just like in next_block