test: construct `mempool_tests` inputs/outputs declaratively #36694

pull alexanderwiederin wants to merge 1 commits into bitcoin:master from alexanderwiederin:declarative-mempool changing 1 files +79 −90
  1. alexanderwiederin commented at 3:04 PM on October 29, 2026: contributor

    Part of #36692. This replaces the field-by-field construction of transaction inputs and outputs in mempool_tests with COutPoint, CTxIn and CTxOut constructor calls.

    It keeps CMutableTransaction as the builder, since a CTransaction constructor taking inputs and outputs directly is still under discussion (#36696). If one is added, the vin/vout lists here can be passed to it directly. Either way, the declarative form makes the constructed transactions easier to read.

    This change is test-only and does not change the constructed transactions.

    The mempool_eviction bench and rbf_tests changes from the earlier version of this PR have been dropped, as they conflict with #36521. They can follow once that is resolved.

  2. test: construct mempool_tests inputs/outputs declaratively
    Replace the field-by-field construction of inputs and outputs in
    mempool_tests with COutPoint, CTxIn and CTxOut constructor calls.
    
    The txChild loop variable in MempoolRemoveTest is changed to uint32_t to
    avoid a narrowing conversion in COutPoint{}. The constructed
    transactions are unchanged.
    b7abd88f0f
  3. DrahtBot commented at 3:05 PM on October 29, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK sedited, yuvicc, janb84

    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

    No conflicts as of last run.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. in src/bench/mempool_eviction.cpp:42 in 30ad3ca75d
      39 | @@ -40,85 +40,79 @@ static void MempoolEviction(benchmark::Bench& bench)
      40 |      const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
      41 |  
      42 |      CMutableTransaction tx1 = CMutableTransaction();
    


    maflcko commented at 4:23 PM on October 29, 2026:
        CMutableTransaction tx1{};
    

    nit: There is no need to type the type twice. But depending on the outcome of #36692, this may be stale anyway. Let's wait a week or two on that issue.

    Also, this pull conflicts with #36521, so let's wait for that to be merged first.


    alexanderwiederin commented at 10:00 AM on November 2, 2026:

    Thanks. The same pattern appears ~20 times across the three files. I’d rather not mix that in and keep it focused on inputs and outputs. If #36692 settles before this PR, I would be happy to extend the PR to construct CTransaction directly.

  5. alexanderwiederin force-pushed on Nov 2, 2026
  6. alexanderwiederin renamed this:
    test, bench: construct mempool inputs/outputs declaratively
    test: construct `mempool_tests` inputs/outputs declaratively
    on Nov 2, 2026
  7. DrahtBot added the label Tests on Nov 2, 2026
  8. alexanderwiederin commented at 1:17 PM on November 2, 2026: contributor

    @maflcko, I have dropeed the mempool_eviction and rbf_tests commits, so this is no longer conflicts with #3651. Those can follow later.

    I don't think the rest needs to wait on #36692: the vin/vout lists here are what a CTransaction constructor would take.

    Let me know what you think!

  9. sedited approved
  10. sedited commented at 3:17 PM on November 4, 2026: contributor

    ACK b7abd88f0f2838b26a09a30e4aa23f18806b962f

  11. yuvicc commented at 5:05 PM on November 4, 2026: contributor

    lgtm ACK b7abd88f0f2838b26a09a30e4aa23f18806b962f

    rfm!

  12. yuvicc commented at 5:14 PM on November 4, 2026: contributor

    opened #36750 for multisig_tests

  13. in src/test/mempool_tests.cpp:81 in b7abd88f0f
      92 | +        txChild[i].vout = {
      93 | +            CTxOut{11000LL, CScript{} << OP_11 << OP_EQUAL},
      94 | +        };
      95 |      }
      96 |      CMutableTransaction txGrandChild[3];
      97 |      for (int i = 0; i < 3; i++)
    


    janb84 commented at 10:18 AM on November 6, 2026:

    NIT: use the size of the array in the loop.

        for (int i = 0; i < std::size(txGrandChild); i++)
    
  14. janb84 commented at 10:28 AM on November 6, 2026: contributor

    tACK b7abd88f0f2838b26a09a30e4aa23f18806b962f

    This PR improves readability of the test (imho). Have checked correctness (is it equal to the previous test).

    Given this is an effort to improve tests I found a small non-blocking NIT. (Given the number of ACK's I would do this as a followup if the discussion in 36696 has been settled )

  15. sedited merged this on Nov 6, 2026
  16. sedited closed this on Nov 6, 2026


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-11-20 15:51 UTC

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