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 (fuzz), 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.
#36809 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36809.svg"></sub> (rpc, wallet: Support BIP322 simple message signing by jaromil)
#36808 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36808.svg"></sub> (iwyu: Fix warnings in src/test/fuzz and treat them as errors by hebasto)
#36786 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36786.svg"></sub> (fuzz: report more events, and check more invariants in connman target by darosior)
#36635 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36635.svg"></sub> (fuzz: Add a target that feeds arbitrary bytes to V2Transport by fametrano)
#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)
#36068 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36068.svg"></sub> (fuzz: reuse one fuzzed wallet across inputs by brunoerg)
#35916 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35916.svg"></sub> (fuzz: improve ipc fuzz coverage by enirox001)
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
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
maflcko force-pushed on Sep 28, 2026
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
maflcko force-pushed on Oct 16, 2026
maflcko force-pushed on Oct 16, 2026
DrahtBot added the label CI failed on Oct 16, 2026
DrahtBot
commented at 10:02 AM on October 16, 2026:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/38883887988/job/116916841745</sub>
<sub>LLM reason (✨ experimental): CI failed because the scripted-diff lint check detected uncommitted changes, including removed cassert and clang-format modifications.</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>
DrahtBot removed the label CI failed on Oct 16, 2026
DrahtBot added the label Needs rebase on Oct 19, 2026
maflcko force-pushed on Oct 19, 2026
maflcko force-pushed on Oct 19, 2026
DrahtBot added the label CI failed on Oct 19, 2026
DrahtBot
commented at 10:10 AM on October 19, 2026:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/39234357822/job/117999721484</sub>
<sub>LLM reason (✨ experimental): The scripted_diff lint check failed because src/test/httpserver_tests.cpp needed a formatting change—an extra blank line between includes.</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>
DrahtBot removed the label CI failed on Oct 19, 2026
DrahtBot removed the label Needs rebase on Oct 19, 2026
DrahtBot added the label Needs rebase on Oct 28, 2026
maflcko marked this as a draft on Oct 29, 2026
maflcko force-pushed on Oct 29, 2026
DrahtBot removed the label Needs rebase on Oct 29, 2026
DrahtBot added the label Needs rebase on Nov 2, 2026
maflcko force-pushed on Nov 2, 2026
DrahtBot removed the label Needs rebase on Nov 2, 2026
maflcko force-pushed on Nov 5, 2026
maflcko added the label CI failed on Nov 5, 2026
maflcko force-pushed on Nov 9, 2026
scripted-diff: [fuzz] Add util/check.h includes for Assert
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 to use util/check.h.
-BEGIN VERIFY SCRIPT-
# Select all fuzz files
paths=(
'src/ipc/test/fuzz'
'src/test/fuzz'
'src/wallet/test/fuzz'
)
# 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-
maflcko marked this as ready for review on Nov 9, 2026
maflcko
commented at 4:50 PM on November 9, 2026:
member
Rebased and limited to fuzz to limit conflicts.
DrahtBot removed the label CI failed on Nov 9, 2026
hebasto approved
hebasto
commented at 7:07 PM on November 9, 2026:
member
ACKfa6c603af6aeac15a7f49477fcf8dc0353d5e1b4.
This somewhat overlaps with #36808. However, this PR is focused and scripted, whereas #36808 is not ready for review yet. In any case, this PR will make the diff in #36808 smaller and easier to review.
DrahtBot requested review from l0rinc on Nov 9, 2026
maflcko renamed this: scripted-diff: [test] Add util/check.h includes for assertions scripted-diff: [fuzz] Add util/check.h includes for assertions on Nov 10, 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-11-20 15:51 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me