test: move more tests to `baseindex_tests` and run them for all indexes #35847

pull mzumsande wants to merge 6 commits into bitcoin:master from mzumsande:202607_baseindex_tests changing 5 files +252 −224
  1. mzumsande commented at 2:06 PM on July 30, 2026: contributor

    In #34897, the baseindex_tests unit test was introduced, meant for tests that test basic index functionality (e.g. reorg or unclean shutdown behavior) that should work regardless of the particular index type. This PR moves two more of these tests (index_reorg_crash, coinstatsindex_unclean_shutdown) from test files of specific indexes into that folder. In the second part, tests are executed sequentially for all index types instead of just one particular one, where applicable.

    Before moving index_reorg_crash I extracted the BuildChain helper to util/mining so that it can be used by multiple tests. While doing that, I simplified the helper a bit.

  2. test: simplify blockfilter test's BuildChain helper
    - CreateBlock was always called with an empty txns arg, so drop it
    and move the rest of CreateBlock into the function.
    - use use_mempool=false instead of removing mempool txns
    - fetch mining interface and consensus params outside of the loop
    954985e6a3
  3. test: move BuildChain helper into test mining util
    This way, different callers can use it.
    The functionality is not already covered by existing helpers:
    These build on the active chain, while for the added function
    a chain built on a provided is returned and not submitted.
    The blockfilter tests will now use the normal TestChain100Setup.
    
    Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    (the majority of code is just moved)
    a3597e2683
  4. test: move index_reorg_crash to baseindex_tests
    It tests generic functionality, nothing specific to the
    blockfilterindex.
    
    Mostly move-only, can be reviewed with
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    2232d6afbe
  5. test: move unclean_shutdown test to baseindex_tests
    It tests generic functionality, nothing specific to the
    coinststatsindex.
    Mostly move-only, can be reviewed with
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    8b959f4c6a
  6. test: make baseindex flush test chain-length agnostic
    This is in preparation for the following commit, where the
    baseindex tests are executed for multiple indexes.
    Since each run increases the chain, make no absolute assumptions.
    11b3e251c4
  7. test: run generic baseindex tests against every index type
    This adds a factory that returns each index type and runs the test
    in a loop against all indexes.
    
    index_reorg_crash is left as a single test since it uses a bespoke index.
    34c03075a5
  8. DrahtBot added the label Tests on Jul 30, 2026
  9. DrahtBot commented at 2:06 PM on July 30, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK fjahr, furszy

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • sync_index(false, tip_height, 0) in src/test/baseindex_tests.cpp
    • m_node.chainman->AcceptBlock(new_block, state, &new_block_index, true, nullptr, nullptr, true) in src/test/baseindex_tests.cpp
    • BuildChain(m_node, tip, coinbase_script_pub_key_A, 10, chainA) in src/test/blockfilter_index_tests.cpp
    • BuildChain(m_node, tip, coinbase_script_pub_key_B, 10, chainB) in src/test/blockfilter_index_tests.cpp
    • BuildChain(m_node, prev_tip, GetScriptForDestination(PKHash(GenerateRandomKey().GetPubKey())), 3, fork) in src/test/baseindex_tests.cpp

    <sup>2026-07-30 14:06:42</sup>

  10. fjahr commented at 2:14 PM on July 30, 2026: contributor

    Concept ACK

  11. furszy commented at 2:16 PM on July 30, 2026: member

    Concept ACK


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: 2026-07-31 20:50 UTC

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