test: construct mempool_tests inputs/outputs declaratively #36694

Manually merged
alexanderwiederin merged 1 commit from declarative-mempool into master 2026-11-06 11:33:16 +00:00 AGit
alexanderwiederin commented 2026-10-29 15:04:56 +00:00 (Migrated from github.com)

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.

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.
DrahtBot commented 2026-10-29 15:05:06 +00:00 (Migrated from github.com)

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36694 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36694.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36694#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36694#pullrequestreview-5770786100), [yuvicc](https://github.com/bitcoin/bitcoin/pull/36694#pullrequestreview-5772472129), [janb84](https://github.com/bitcoin/bitcoin/pull/36694#pullrequestreview-5798726327) | 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-->
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: b7abd88f0f28 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:965af1044d9e41839565702e4d9bd0a751eda81f6e8b6402747fa296ef84ebea:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:e310efb202bd1283bcdd25d5748078df1219c8ac --> <!-- ralph-head:b7abd88f0f2838b26a09a30e4aa23f18806b962f --> <!-- ralph-case:bc2657e0143e8ad121340938d979066c95da739c6525c9332f47015e30089af9 --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`b7abd88f0f28`](<https://git.fish.foo/bitcoin/bitcoin/commit/b7abd88f0f2838b26a09a30e4aa23f18806b962f>) · [Full review report](<https://review.fish.foo/traces/36694-b7abd88f0f2838b26a09a30e4aa23f18806b962f-1980-2.html>) · [Previous reports](<https://review.fish.foo/traces/36694/>) [permalink](<https://review.fish.foo/traces/36694-b7abd88f0f2838b26a09a30e4aa23f18806b962f-1980-2.html>)
maflcko (Migrated from github.com) reviewed 2026-10-29 16:23:41 +00:00
maflcko (Migrated from github.com) commented 2026-10-29 16:23:41 +00:00
    CMutableTransaction tx1{};

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

Also, this pull conflicts with https://github.com/bitcoin/bitcoin/pull/36521, so let's wait for that to be merged first.

```suggestion CMutableTransaction tx1{}; ``` nit: There is no need to type the type twice. But depending on the outcome of https://github.com/bitcoin/bitcoin/issues/36692, this may be stale anyway. Let's wait a week or two on that issue. Also, this pull conflicts with https://github.com/bitcoin/bitcoin/pull/36521, so let's wait for that to be merged first.
alexanderwiederin (Migrated from github.com) reviewed 2026-11-02 10:00:21 +00:00
alexanderwiederin (Migrated from github.com) commented 2026-11-02 10:00:21 +00:00

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.

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.
alexanderwiederin commented 2026-11-02 13:17:33 +00:00 (Migrated from github.com)

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

@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!
sedited (Migrated from github.com) approved these changes 2026-11-04 15:17:31 +00:00
sedited (Migrated from github.com) left a comment
ACK b7abd88f0f2838b26a09a30e4aa23f18806b962f
yuvicc (Migrated from github.com) reviewed 2026-11-04 17:05:21 +00:00
yuvicc (Migrated from github.com) left a comment

lgtm ACK b7abd88f0f

rfm!

lgtm ACK b7abd88f0f2838b26a09a30e4aa23f18806b962f rfm!
yuvicc commented 2026-11-04 17:14:01 +00:00 (Migrated from github.com)

opened #36750 for multisig_tests

opened #36750 for `multisig_tests`
janb84 (Migrated from github.com) reviewed 2026-11-06 10:28:20 +00:00
janb84 (Migrated from github.com) left a comment

tACK b7abd88f0f

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 )

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](https://github.com/bitcoin/bitcoin/pull/36696) has been settled )
janb84 (Migrated from github.com) commented 2026-11-06 10:18:50 +00:00

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

    for (int i = 0; i < std::size(txGrandChild); i++)
NIT: use the size of the array in the loop. ```suggestion for (int i = 0; i < std::size(txGrandChild); i++) ```
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36694
No description provided.