test: make tx_mempool_block_doublespend cases independent #36830

Manually merged
alexanderwiederin merged 2 commits from split-txvalidationcache_tests into master 2026-11-25 08:56:40 +00:00 AGit
alexanderwiederin commented 2026-11-10 17:48:00 +00:00 (Migrated from github.com)

Found during #36692: remove test state that is shared and modified across cases.

tx_mempool_block_doublespend ran four cases against one chain and mempool, removing each case’s mempool transaction by hand before the next one. Each case is now its own test with a fresh setup that builds the two spends. The first commit also fixes the last case’s comment, which had the mempool and block spends reversed. The checks are unchanged.

The second commit makes the two spends distinct transactions. Previously they were identical (deterministic signing), so in the last case the mempool transaction was removed because it was mined rather than as a conflict. The rejection cases are unaffected: they fail with bad-txns-inputs-missingorspent either way.

Found during #36692: remove test state that is shared and modified across cases. `tx_mempool_block_doublespend` ran four cases against one chain and mempool, removing each case’s mempool transaction by hand before the next one. Each case is now its own test with a fresh setup that builds the two spends. The first commit also fixes the last case’s comment, which had the mempool and block spends reversed. The checks are unchanged. The second commit makes the two spends distinct transactions. Previously they were identical (deterministic signing), so in the last case the mempool transaction was removed because it was mined rather than as a conflict. The rejection cases are unaffected: they fail with `bad-txns-inputs-missingorspent` either way.
DrahtBot commented 2026-11-10 17:48:13 +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 yuvicc, janb84, maflcko

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

<!--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/36830 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36830.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36830#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 | [yuvicc](https://github.com/bitcoin/bitcoin/pull/36830#issuecomment-6803585168), [janb84](https://github.com/bitcoin/bitcoin/pull/36830#pullrequestreview-6025750537), [maflcko](https://github.com/bitcoin/bitcoin/pull/36830#issuecomment-7143226207) | 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-->
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: 0d98c438ebc1 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7eebed8027c96ac27bcd79eeb7a88e35799cd96eb8fbacf34d3257986a959f64:cdc1bd61213c9363d5bb4c7b7ee073ccfd6fecdafbb2c4c18d9d9e031a6afcf8 --> <!-- ralph-base:6f1365e34f518fdc9fb963cd246abeb47a34ce8b --> <!-- ralph-head:0d98c438ebc124ca4252bdd2855d62691e030e58 --> <!-- ralph-case:5f41d1f97851fb58417206aae7819ec71429f0c892b0b486ff2d43a582697a3c --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`0d98c438ebc1`](<https://git.fish.foo/bitcoin/bitcoin/commit/0d98c438ebc124ca4252bdd2855d62691e030e58>) · [Review report](<https://review.fish.foo/report/36830-0d98c438ebc124ca4252bdd2855d62691e030e58-2515-3.html>) · [Previous reports](<https://review.fish.foo/traces/36830/>) [permalink](<https://review.fish.foo/report/36830-0d98c438ebc124ca4252bdd2855d62691e030e58-2515-3.html>)
yuvicc (Migrated from github.com) reviewed 2026-11-11 06:08:12 +00:00
yuvicc (Migrated from github.com) left a comment

cr-ACK 19bb40c987

Verified that the checks match.

cr-ACK 19bb40c9872b8695c45e8a977398cb294eb64187 Verified that the checks match.
yuvicc (Migrated from github.com) commented 2026-11-11 05:51:48 +00:00

Maybe we can use the helper already provided by setup_common.h: CreateValidMempoolTransaction() instead of creating by hand? this would drop the const-ness but is that a problem?

Maybe we can use the helper already provided by `setup_common.h`: `CreateValidMempoolTransaction()` instead of creating by hand? this would drop the const-ness but is that a problem?
yuvicc (Migrated from github.com) commented 2026-11-11 06:07:35 +00:00

the last case could assert more: something like spends[0] and spends[1] have different hashes? Also, there is typo in commit message determinitsic -> deterministic in second commit.

the last case could assert more: something like `spends[0]` and `spends[1]` have different hashes? Also, there is typo in commit message `determinitsic` -> `deterministic` in second commit.
alexanderwiederin (Migrated from github.com) reviewed 2026-11-11 08:50:01 +00:00
alexanderwiederin (Migrated from github.com) commented 2026-11-11 08:50:01 +00:00

Good idea, but CreateValidMempoolTransaction builds the transactions slightly differently (version 2 and an RBF nSequence instead of version 1 and final), so it would change the test’s transactions, while the first commit should be a pure refactoring. I’d prefer to keep MakeSpend here - at least for now.

Good idea, but `CreateValidMempoolTransaction` builds the transactions slightly differently (version 2 and an RBF nSequence instead of version 1 and final), so it would change the test’s transactions, while the first commit should be a pure refactoring. I’d prefer to keep `MakeSpend` here - at least for now.
alexanderwiederin (Migrated from github.com) reviewed 2026-11-11 09:05:34 +00:00
alexanderwiederin (Migrated from github.com) commented 2026-11-11 09:05:34 +00:00

Taken - thanks!

Taken - thanks!
yuvicc commented 2026-11-11 18:09:27 +00:00 (Migrated from github.com)

lgtm ACK 0d98c438eb

signature
iJEEARYKADkWIQRxIqfV4fHauqeDZkLHO83HCSJ4EQUCavSuehsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMiwwLDMACgkQxzvNxwkieBEa3gEAvJU8Pjvey0r2cuS/D4mX
npg5+DCKk0NsYGRzgat+A2AA/jY4TkI2FmjtjVAw6YJIaDw6EUTTlDvSXJxvFwsQ
pd8F
=xcDI
lgtm ACK 0d98c438ebc124ca4252bdd2855d62691e030e58 <details> <summary>signature</summary> ```bash iJEEARYKADkWIQRxIqfV4fHauqeDZkLHO83HCSJ4EQUCavSuehsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMiwwLDMACgkQxzvNxwkieBEa3gEAvJU8Pjvey0r2cuS/D4mX npg5+DCKk0NsYGRzgat+A2AA/jY4TkI2FmjtjVAw6YJIaDw6EUTTlDvSXJxvFwsQ pd8F =xcDI ``` </details>
janb84 (Migrated from github.com) reviewed 2026-11-23 16:57:20 +00:00
janb84 (Migrated from github.com) left a comment

ACK 0d98c438eb

LGTM, small comment NIT but very minor.

ACK 0d98c438ebc124ca4252bdd2855d62691e030e58 LGTM, small comment NIT but very minor.
janb84 (Migrated from github.com) commented 2026-11-23 16:56:34 +00:00

Small NIT: Maybe make the (new) distinctness more explicit in the comment.

    // Two conflicting spends of a double-spend of a mature coinbase txn.
Small NIT: Maybe make the (new) distinctness more explicit in the comment. ```suggestion // Two conflicting spends of a double-spend of a mature coinbase txn. ```
maflcko commented 2026-11-24 20:13:57 +00:00 (Migrated from github.com)

review ACK 0d98c438eb 🏉

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 0d98c438ebc124ca4252bdd2855d62691e030e58 🏉
N6a2/vvMkULB8lKlUItmWsqwjUb7fpEV/I/ihdH1tssMKMJWZL/SSENHp5HJnc5cmHy7mTCRfneO8iyHvx4pDg==
review ACK 0d98c438ebc124ca4252bdd2855d62691e030e58 🏉 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK 0d98c438ebc124ca4252bdd2855d62691e030e58 🏉 N6a2/vvMkULB8lKlUItmWsqwjUb7fpEV/I/ihdH1tssMKMJWZL/SSENHp5HJnc5cmHy7mTCRfneO8iyHvx4pDg== ``` </details>
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!36830
No description provided.