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.
This commit is contained in:
Sebastian Falbesoner
2025-06-14 19:15:49 +02:00
parent f3c791d2e3
commit 0f044e82bd

View File

@@ -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