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
    ACK jeanpablojp, sedited
    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.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35713 (Remove boost as a unit test runner by rustaceanrob)
    • #35646 (RFC: Separate out runtime errors from BlockValidationState using util::Expected by yuvicc)
    • #35570 (refactor: Change some validation.cpp methods to return BlockValidationState by optout21)
    • #35300 (mining: add precious option to IPC block submission by w0xlt)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

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

  12. jeanpablojp commented at 9:01 PM on August 13, 2026: contributor

    tACK 34c03075a5a01ced1211d33362b555edf43bbfd7

    All green. The flush test now covers all four index types instead of one.

  13. DrahtBot requested review from fjahr on Aug 13, 2026
  14. DrahtBot requested review from furszy on Aug 13, 2026
  15. sedited approved
  16. sedited commented at 2:05 PM on August 14, 2026: contributor

    ACK 34c03075a5a01ced1211d33362b555edf43bbfd7

  17. fanquake merged this on Aug 14, 2026
  18. fanquake closed this on Aug 14, 2026

  19. Kino1994 referenced this in commit 8af1273690 on Aug 19, 2026
  20. in src/test/baseindex_tests.cpp:148 in 34c03075a5
     150 | +
     151 | +        {
     152 | +            auto index{make_index(m_node)};
     153 | +            BOOST_REQUIRE(index->Init());
     154 | +            // Make sure the index can be loaded.
     155 | +            BOOST_REQUIRE(index->StartBackgroundSync());
    


    l0rinc commented at 3:38 AM on August 23, 2026:

    BOOST_CHECK_EQUAL(index->GetSummary().best_block_height, 0) passed here, fixed in https://github.com/bitcoin/bitcoin/pull/36059


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-08-23 22:51 UTC

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