maflcko
commented at 9:30 AM on August 25, 2026:
member
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 (bench, fuzz, unit), other code can be done later, if there is need to.
DrahtBot renamed this: scripted-diff: [test] replace assert with Assert scripted-diff: [test] replace assert with Assert on Aug 25, 2026
DrahtBot added the label Refactoring on Aug 25, 2026
DrahtBot
commented at 9:30 AM on August 25, 2026:
contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#bitcoin-core/gui/945 <sub><img src="https://drahtbot.space/ack_count/bitcoin-core/gui/945.svg"></sub> (qt: Fix sign message address book filtering by Bushstar)
#36386 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36386.svg"></sub> (compressor: oversized script decoding can leave a spendable script by l0rinc)
#36317 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36317.svg"></sub> (mempool, fees: stop treating different witness variants as mined by l0rinc)
#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 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> ([RFC] Enable -Wunused by fanquake)
#36159 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36159.svg"></sub> (http: Improve HTTPRemoteClient::MaybeDisconnect() by hodlinator)
#36097 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36097.svg"></sub> (mining: replace interrupt methods with cancellation arguments by xyzconstant)
#36091 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36091.svg"></sub> (test: Add debug output to common tested types by rustaceanrob)
#36068 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36068.svg"></sub> (fuzz: reuse one fuzzed wallet across inputs by brunoerg)
#36040 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36040.svg"></sub> (Wallet: Don't backdate locktime rbf by Bicaru20)
#36000 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36000.svg"></sub> (validation: prefetch blocks while connecting by l0rinc)
#35916 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35916.svg"></sub> (fuzz: improve ipc fuzz coverage by enirox001)
#35731 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35731.svg"></sub> (Indexes: Harden the flush-error notification invariant by arejula27)
#35714 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35714.svg"></sub> (validation: return block-file flush errors by l0rinc)
#35713 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35713.svg"></sub> (Remove boost as a unit test runner by rustaceanrob)
#35300 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35300.svg"></sub> (mining: add precious option to IPC block submission by w0xlt)
#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)
#34778 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34778.svg"></sub> (logging: rewrite macros to enforce restrictions at compile-time, improve efficiency and usability by ryanofsky)
#33922 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33922.svg"></sub> (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)
#32387 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32387.svg"></sub> (ipc: add windows support by ryanofsky)
#30343 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/30343.svg"></sub> (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
#29256 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29256.svg"></sub> (log, refactor: Allow log macros to accept context arguments by ryanofsky)
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-->
DrahtBot added the label CI failed on Aug 25, 2026
DrahtBot
commented at 10:52 AM on August 25, 2026:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/32832295932/job/97753466551</sub>
<sub>LLM reason (✨ experimental): CI failed due to a C++ build error treated as fatal (-Werror=return-type) in bench/sign_transaction.cpp where an Assert(false) lambda triggers “control reaches end of non-void function.”</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
maflcko marked this as a draft on Aug 25, 2026
maflcko
commented at 12:15 PM on August 25, 2026:
member
Hmm, I guess Assert(0/false) being a function trips GCC into thinking it can return? Though, the optimized codegen is unaffected on GCC. Funnily clang doesn't warn, but pessimises codegen: https://godbolt.org/z/h79K1scWK
I guess that means we could add an explicit #define AssertUnreachable() assertion_fail(std::source_location::current(), "Unreachable code")
DrahtBot added the label Needs rebase on Aug 26, 2026
maflcko force-pushed on Aug 26, 2026
DrahtBot removed the label Needs rebase on Aug 26, 2026
in
src/test/fuzz/mini_miner.cpp:122
in
3440553098
124 | - assert(!mini_miner.IsReadyToCalculate()); 125 | + Assert(total_bumpfee.has_value()); 126 | + Assert(!mini_miner.IsReadyToCalculate());
127 | }
128 | // Overlapping ancestry across multiple outpoints can only reduce the total bump fee.
129 | assert (sum_fees >= *total_bumpfee);
jeanpablojp
commented at 7:36 PM on August 26, 2026:
This one doesn't match \<assert\( because of the space, and it's the only one left in the swept paths. lint_c_assert uses the same regex, so it doesn't catch it either. I added assert (1); to a covered file and the linter still passes. How about \<assert\s*\(?
This is why I only migrated the problematic usages with side effects - but I'm glad you're taking a stab at it systemically, even if just for tests for now
in
test/lint/test_runner/src/lint_cpp.rs:164
in
3440553098
jeanpablojp
commented at 7:36 PM on August 26, 2026:
src/ipc/test/ is left out here, and src/ipc/test/fuzz/ipc.cpp has six assert(. lint-tests.py already counts that directory as part of the test suite. Is this intentional?
jeanpablojp
commented at 5:02 PM on August 29, 2026:
The comma in 'src/ipc/test/', ends up inside the element, so it still matches nothing.
maflcko
commented at 6:55 AM on September 1, 2026:
The comma in 'src/ipc/test/', ends up inside the element, so it still matches nothing.
Whoops, fixed. Thx
maflcko renamed this: scripted-diff: [test] replace assert with Assert scripted-diff: [test] Add util/check.h includes for assertions on Aug 29, 2026
DrahtBot renamed this: scripted-diff: [test] Add util/check.h includes for assertions scripted-diff: [test] Add util/check.h includes for assertions on Aug 29, 2026
maflcko force-pushed on Aug 29, 2026
DrahtBot removed the label CI failed on Aug 29, 2026
maflcko force-pushed on Aug 31, 2026
DrahtBot added the label Needs rebase on Aug 31, 2026
maflcko force-pushed on Sep 1, 2026
maflcko force-pushed on Sep 1, 2026
DrahtBot added the label CI failed on Sep 1, 2026
DrahtBot removed the label Needs rebase on Sep 1, 2026
DrahtBot removed the label CI failed on Sep 1, 2026
DrahtBot added the label Needs rebase on Sep 5, 2026
maflcko added the label Tests on Sep 22, 2026
maflcko removed the label Tests on Sep 22, 2026
maflcko force-pushed on Sep 22, 2026
maflcko force-pushed on Sep 22, 2026
maflcko marked this as ready for review on Sep 22, 2026
maflcko
commented at 1:36 PM on September 22, 2026:
member
rebased on top of the recent iwyu changes to drop hunks already merged, also taken out of draft
DrahtBot removed the label Needs rebase on Sep 22, 2026
DrahtBot added the label Needs rebase on Sep 22, 2026
maflcko force-pushed on Sep 23, 2026
DrahtBot removed the label Needs rebase on Sep 23, 2026
DrahtBot added the label Needs rebase on Sep 25, 2026
maflcko force-pushed on Sep 25, 2026
DrahtBot removed the label Needs rebase on Sep 25, 2026
l0rinc
commented at 6:47 PM on September 25, 2026:
contributor
Concept ACK, though the scripted diffs will conflict with most open PRs.
I expect this to be in review for a while, so maybe we could extract the lint commit into a separate PR - that one is conflict-free and should pass quickly. And once it's in, both scripted diffs here can be done in a single commit: the formatter can just work on the pending diff right after the insertions, instead of formatting the previous commit in a separate step.
Also, since the formatter fixes placement anyway, could the include insertion skip the first-#include line-number lookup and just insert at the top of the file?
DrahtBot added the label Needs rebase on Sep 25, 2026
scripted-diff: [test] Add util/check.h includes for assertions
The project has a compile error when compiled without assertions in
util/check.h. Thus, util/check.h should be included for all assertions.
So do that with a scripted-diff for Assert and assert, and remove the
cassert include, which is exported from util/check.h.
-BEGIN VERIFY SCRIPT-
# Select all test .cpp and .h files
paths=(
'src/bench/'
'src/ipc/test/'
'src/qt/test/'
'src/test/'
'src/wallet/test/'
':(exclude)src/bench/nanobench.h'
)
# Add the util/check.h includes
for f in $(git grep -l --extended-regexp "\<(a|A)ssert\(" -- "${paths[@]}"); do
if ! grep --quiet "util/check.h" "$f"; then
line=$(grep --line-number --max-count=1 '^#include' "$f" | cut --delimiter=: --fields=1)
sed --in-place "${line}i#include <util/check.h>" "$f"
fi
done
# Remove cassert includes
for f in $(git grep -l '<cassert>' -- "${paths[@]}"); do
sed --in-place '/^#include <cassert>$/d' "$f"
done
-END VERIFY SCRIPT-
faa0d3b032
lint: Allow clang-format to be used in scripted-diff
Also, remove the unused pushd/popd. No command in this file requires a
special PWD.
maflcko
commented at 4:04 PM on September 28, 2026:
member
Concept ACK, though the scripted diffs will conflict with most open PRs.
I went through all conflicts and there are about 6 acks in the list. Also, conflicts should be trivial to resolve in the include list, so I think it is fine. But I am happy to wait until this invalidates less acks.
I expect this to be in review for a while, so maybe we could extract the lint commit into a separate PR - that one is conflict-free and should pass quickly. And once it's in, both scripted diffs here can be done in a single commit:
The changes and scripts should be easy enough to keep bundled here. Also, I think it is easier to review the addition and the sorting separately.
could the include insertion skip the first-#include line-number lookup and just insert at the top of the file?
clang-format can't move includes over // comment lines. So this won't work.
Rebased and left as-is for now.
DrahtBot removed the label Needs rebase on Sep 28, 2026
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-10-11 09:51 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me