test: Avoid intermittent error in assert_equal(pruneheight_new, 248) #31468

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2412-test-fix changing 1 files +25 −24
  1. maflcko commented at 3:57 pm on December 11, 2024: member

    Fixes #31446

    The test uses the P2P network to sync blocks, which has no inherent guarantee that the blocks are sent and received in the right order, assuming the headers are received first.

    This can mean that the first block file is flushed with block at height 249 and block at height 248 is added to the second file. In the log it looks like: Leaving block file 0: CBlockFileInfo(blocks=249, size=65319, heights=0...249, time=2011-02-02...2024-12-03) (onto 1) (height 248). The test assumes that the height of the last pruned block in the first file is 248, expecting it to look like: Leaving block file 0: CBlockFileInfo(blocks=249, size=65319, heights=0...248, time=2011-02-02...2024-12-09) (onto 1) (height 249) .

    Fix the issue by using a linear dumb sync.

  2. DrahtBot commented at 3:57 pm on December 11, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31468.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK mzumsande

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Dec 11, 2024
  4. in test/functional/feature_index_prune.py:32 in faf62ad6ec outdated
    28+
    29+    def linear_sync(self, node_from, *, height_from=None):
    30+        # Linear sync over RPC, because P2P sync may not be linear
    31+        to_height = node_from.getblockcount()
    32+        for n in self.nodes:
    33+            for i in range(height_from or n.getblockcount(), to_height + 1):
    


    mzumsande commented at 6:16 pm on December 12, 2024:
    could start at n.getblockcount() + 1, nodes will already have the block at n.getblockcount().

    maflcko commented at 10:07 am on December 13, 2024:

    Thx, done. Also made the test about as fast as before.

  5. mzumsande commented at 6:29 pm on December 12, 2024: contributor

    Code Review ACK faf62ad6ecc8905db75a1e772d2b033081058f1b

    This makes the test slower (by a factor ~2), but it’s already in the list of extended tests anyway, so probably not a big issue.

  6. test: Avoid intermittent error in assert_equal(pruneheight_new, 248) fa0998f0a0
  7. maflcko force-pushed on Dec 13, 2024
  8. mzumsande commented at 6:34 pm on December 17, 2024: contributor
    Code Review ACK fa0998f0a028161fe7264d0e81af36ffdcb43384

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me