Merge bitcoin/bitcoin#32312: test: Fix feature_pruning test after nTime typo fix

2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c test: Use uninvolved pruned node in feature_pruning undo test (enoch)
772ba7f9ce09e836a51636524a8a96a23946d658 test: Fix nTimes typo in feature_pruning test (enoch)

Pull request description:

  This PR contains two commits:

  1. Fixes a typo in feature_pruning.py where 'nTimes' was incorrectly
     used instead of 'nTime'. This typo caused the test to always reset
     mine_large_blocks.nTime to 0, rather than only on the first run.

  2. Fixes the test failure exposed by the typo fix. The
     test_pruneheight_undo_presence test was failing because it was using
     node 2, which is involved in reorg testing and could be on a
     different chain than other nodes. The solution switches to using
     node 5, which is also a pruned node but isn't involved in reorg
     testing.

  Testing:
  - Ran test/functional/feature_pruning.py multiple times to verify
    consistent passing
  - Verified that the test now passes with the correct nTime variable name
  - Confirmed the test behavior matches the intended functionality of
    verifying pruned block availability
  - Ran the full test suite to ensure the changes did not introduce any
    regressions or affect other tests

  Thanks to fjahr for his assistance in diagnosing the issue and
  suggesting the solution.

  This fixes the test failure reported in #32249

ACKs for top commit:
  fjahr:
    tACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  maflcko:
    lgtm ACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  naiyoma:
     tACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  stratospher:
    tested ACK 2aa63d5. verified that `nTime` is being incremented now.

Tree-SHA512: a543528fd4eeb30e978c0b43cfa109768252edaf1f94679dbbc7fe684122c00da34224e2cc1abd2a265af1b267eef1cd34246207946cf7d8e93d2c0f11aa56d8
This commit is contained in:
merge-script 2025-05-13 16:30:25 -04:00
commit bac43b957e
No known key found for this signature in database
GPG Key ID: BA03F4DBE0C63FB4

View File

@ -41,7 +41,7 @@ def mine_large_blocks(node, n):
# Set the nTime if this is the first time this function has been called. # Set the nTime if this is the first time this function has been called.
# A static variable ensures that time is monotonicly increasing and is therefore # A static variable ensures that time is monotonicly increasing and is therefore
# different for each block created => blockhash is unique. # different for each block created => blockhash is unique.
if "nTimes" not in mine_large_blocks.__dict__: if "nTime" not in mine_large_blocks.__dict__:
mine_large_blocks.nTime = 0 mine_large_blocks.nTime = 0
# Get the block parameters for the first block # Get the block parameters for the first block
@ -498,11 +498,11 @@ class PruneTest(BitcoinTestFramework):
"start", [{"desc": f"raw({false_positive_spk.hex()})"}], 0, 0, "basic", {"filter_false_positives": True}) "start", [{"desc": f"raw({false_positive_spk.hex()})"}], 0, 0, "basic", {"filter_false_positives": True})
def test_pruneheight_undo_presence(self): def test_pruneheight_undo_presence(self):
node = self.nodes[2] node = self.nodes[5]
pruneheight = node.getblockchaininfo()["pruneheight"] pruneheight = node.getblockchaininfo()["pruneheight"]
fetch_block = node.getblockhash(pruneheight - 1) fetch_block = node.getblockhash(pruneheight - 1)
self.connect_nodes(1, 2) self.connect_nodes(1, 5)
peers = node.getpeerinfo() peers = node.getpeerinfo()
node.getblockfrompeer(fetch_block, peers[0]["id"]) node.getblockfrompeer(fetch_block, peers[0]["id"])
self.wait_until(lambda: not try_rpc(-1, "Block not available (pruned data)", node.getblock, fetch_block), timeout=5) self.wait_until(lambda: not try_rpc(-1, "Block not available (pruned data)", node.getblock, fetch_block), timeout=5)