WIP: scripted-diff: [test] Add util/check.h includes for assertions #36946

Draft
maflcko wants to merge 2 commits from 2608-test-assert into master AGit
maflcko commented 2026-11-22 13:12:21 +00:00 (Migrated from github.com)

In test code, assert is used. This is perfectly fine, but sometimes confusion arises, when it is unclear whether NDEBUG can disable the assertions, or whether to use assert or Assert.

Avoid that confusion in test code with a scripted replacement to add the util/check.h include. The changes here will also make it easier to run IWYU.

Scope: This change is only about test code, other code can be done later, if there is need to.

(Currently a draft, because it waits on other stuff)

In test code, `assert` is used. This is perfectly fine, but sometimes confusion arises, when it is unclear whether `NDEBUG` can disable the assertions, or whether to use `assert` or `Assert`. Avoid that confusion in test code with a scripted replacement to add the util/check.h include. The changes here will also make it easier to run IWYU. Scope: This change is only about test code, other code can be done later, if there is need to. (Currently a draft, because it waits on other stuff)
DrahtBot commented 2026-11-22 13:12:30 +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.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37094 (validation: validate assumeutxo snapshots with a single chainstate by fjahr)
  • #36971 (blockstorage: fix partial-mask assertions and genesis availability checks by l0rinc)
  • #36844 (iwyu: Fix warnings in more modules in src/ and treat them as errors by hebasto)
  • #36832 (test: speed up wallet unit test by ViniciusCestarii)
  • #36831 (test: split test_IsStandard into independent test cases by yuvicc)
  • #36737 (qa: check more socket API invariants for each platform we support by darosior)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36548 (net: serve MSG_BLOCK by stripping witnesses in place by l0rinc)
  • #36520 (interfaces: Avoid node crashes from invalid Chain IPC calls by ryanofsky)
  • #36506 (p2p: plug "tier 1" 1p1c liveness holes by instagibbs)
  • #36386 (compressor: reject oversized scripts during deserialization by l0rinc)
  • #36280 (validation: throw when a compressed script can't be decompressed by furszy)
  • #36167 (build: Enable -Wunused by fanquake)
  • #36000 (validation: prefetch blocks while connecting by l0rinc)
  • #35731 (Indexes: Harden the flush-error notification invariant by arejula27)
  • #35713 (Remove boost as a unit test runner by rustaceanrob)
  • #35302 (Silent Payments: Sending (take 2) by Eunovo)
  • #35003 (validation: improve block data I/O error handling in P2P paths by furszy)
  • #32387 (ipc: add windows support by ryanofsky)
  • #27260 (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl)

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.

<!--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/36946 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36946.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36946#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. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37094](https://github.com/bitcoin/bitcoin/pull/37094) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37094.svg"></sub> (validation: validate assumeutxo snapshots with a single chainstate by fjahr) * [#36971](https://github.com/bitcoin/bitcoin/pull/36971) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36971.svg"></sub> (blockstorage: fix partial-mask assertions and genesis availability checks by l0rinc) * [#36844](https://github.com/bitcoin/bitcoin/pull/36844) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36844.svg"></sub> (iwyu: Fix warnings in more modules in `src/` and treat them as errors by hebasto) * [#36832](https://github.com/bitcoin/bitcoin/pull/36832) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36832.svg"></sub> (test: speed up wallet unit test by ViniciusCestarii) * [#36831](https://github.com/bitcoin/bitcoin/pull/36831) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36831.svg"></sub> (test: split `test_IsStandard` into independent test cases by yuvicc) * [#36737](https://github.com/bitcoin/bitcoin/pull/36737) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36737.svg"></sub> (qa: check more socket API invariants for each platform we support by darosior) * [#36603](https://github.com/bitcoin/bitcoin/pull/36603) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36603.svg"></sub> (Improve loadtxoutset performance by ajtowns) * [#36548](https://github.com/bitcoin/bitcoin/pull/36548) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36548.svg"></sub> (net: serve `MSG_BLOCK` by stripping witnesses in place by l0rinc) * [#36520](https://github.com/bitcoin/bitcoin/pull/36520) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36520.svg"></sub> (interfaces: Avoid node crashes from invalid Chain IPC calls by ryanofsky) * [#36506](https://github.com/bitcoin/bitcoin/pull/36506) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36506.svg"></sub> (p2p: plug "tier 1" 1p1c liveness holes by instagibbs) * [#36386](https://github.com/bitcoin/bitcoin/pull/36386) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36386.svg"></sub> (compressor: reject oversized scripts during deserialization by l0rinc) * [#36280](https://github.com/bitcoin/bitcoin/pull/36280) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36280.svg"></sub> (validation: throw when a compressed script can't be decompressed by furszy) * [#36167](https://github.com/bitcoin/bitcoin/pull/36167) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> (build: Enable `-Wunused` by fanquake) * [#36000](https://github.com/bitcoin/bitcoin/pull/36000) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36000.svg"></sub> (validation: prefetch blocks while connecting by l0rinc) * [#35731](https://github.com/bitcoin/bitcoin/pull/35731) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35731.svg"></sub> (Indexes: Harden the flush-error notification invariant by arejula27) * [#35713](https://github.com/bitcoin/bitcoin/pull/35713) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35713.svg"></sub> (Remove boost as a unit test runner by rustaceanrob) * [#35302](https://github.com/bitcoin/bitcoin/pull/35302) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35302.svg"></sub> (Silent Payments: Sending (take 2) by Eunovo) * [#35003](https://github.com/bitcoin/bitcoin/pull/35003) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35003.svg"></sub> (validation: improve block data I/O error handling in P2P paths by furszy) * [#32387](https://github.com/bitcoin/bitcoin/pull/32387) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32387.svg"></sub> (ipc: add windows support by ryanofsky) * [#27260](https://github.com/bitcoin/bitcoin/pull/27260) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27260.svg"></sub> (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl) 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-->
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: faece5db2e6b · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:3705f06c6a27c475c77f2533c4d016ac03c829c839b7b538bba5e4768ccf54f1:1ed10c4979af6fc548d6b8d4534d505e02e84ac4b0aa4f8633555b2ba75119e8 --> <!-- ralph-base:19128e8b77553e4362fcbf3cb8f3f7dc5a2e4253 --> <!-- ralph-head:faece5db2e6bbde8d4b817c9a1ae5d4af1e0005c --> <!-- ralph-case:1bc0884d10373d6cfc8667094ddc02edddf82770a5b82b46d55f0b3b42832c76 --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`faece5db2e6b`](<https://git.fish.foo/bitcoin/bitcoin/commit/faece5db2e6bbde8d4b817c9a1ae5d4af1e0005c>) · [Review report](<https://review.fish.foo/report/36946-faece5db2e6bbde8d4b817c9a1ae5d4af1e0005c-2935-1.html>) · [Previous reports](<https://review.fish.foo/traces/36946/>) [permalink](<https://review.fish.foo/report/36946-faece5db2e6bbde8d4b817c9a1ae5d4af1e0005c-2935-1.html>)
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!36946
No description provided.