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

full analysis

https://github.com/bitcoin/bitcoin/pull/36074 · maflcko · +341/-225 in 155 files, 3 commits · labels: Refactoring, Needs rebase · draft

Goal

  • Clarify assertion header usage across test and fuzz harnesses to prevent ambiguity around disabled checks
  • Make automated header analysis tooling easier to run across tests

This scripted-diff PR adds `#include <util/check.h>` across test, bench, and fuzz harnesses where assertions are used, while removing now-redundant `<cassert>` includes. It also updates CI lint setup to enable `clang-format` in scripted diffs and formats the resulting includes.

Problem: In test code, direct usage of `assert` creates ambiguity regarding whether `NDEBUG` could disable checks or whether `Assert` should be used instead. Missing direct includes also complicate tooling like Include What You Use (IWYU).

Category: Test infrastructure (#42 of 45)

P4 · cleanup

  • P4 because this is a mechanical header cleanup across test files with no change to logic or coverage
  • Benefits maintainers running automated header analysis tools like Include What You Use

P4 because this is a mechanical header cleanup across test files with no change to testing logic or coverage. The author noted the intent is to avoid confusion around NDEBUG and make running IWYU easier.

Membership: Touches 150+ test, fuzz, and benchmark files to normalize assertion header includes and updates lint harness scripts.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1

Category: Build and CI (#54 of 55)

P4 · cleanup

  • P4 because the build change is confined to a minor CI lint environment adjustment
  • Carries minimal impact beyond enabling clang-format for scripted diffs

P4 because the build system impact is limited to a minor adjustment in the CI lint container installation script to support clang-format.

Membership: Modifies ci/lint/01_install.sh to allow clang-format in scripted diffs.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0

Reviewability: Stale: Needs rebase

  • Needs rebase across many conflicting PRs, and author noted merge friction may prevent landing

The PR has merge conflicts with 24 open PRs, is marked dirty by GitHub, and the author acknowledged high conflict friction.

Author status: active, but noted on 2026-08-29 that high conflict volume means 'this likely won't make it to merge'

Resolved concerns:

  • GCC warnings on Assert(0/false) codegen prompted the author to drop commits converting asserts directly to Asserts
  • Regex matching in lint scripts for space-separated assert invocations and ipc test paths was pointed out by jeanpablojp and addressed

Agreement: Positive

  • General support for systematically cleaning up assertion headers in test files (l0rinc)
  • Assisted with scripted-diff regex matching and test runner paths (jeanpablojp)

Positive feedback on the goal (l0rinc); minor linter regex issues resolved (jeanpablojp).

Reviewers welcomed the systemic cleanup of assertion headers in tests, though the author expressed skepticism about landing it given the rebasing friction.

  • l0rinc: 'I'm glad you're taking a stab at it systemically, even if just for tests for now'
  • jeanpablojp helped refine the scripted-diff regex and test runner paths

Review verdicts (DrahtBot): 0

Files

544 lines under test/bench/ci.

  • ci/lint/01_install.sh +6/-11
  • src/qt/test/wallettests.cpp +9/-8
  • src/qt/test/addressbooktests.cpp +8/-8
  • src/wallet/test/wallet_tests.cpp +8/-8
  • src/test/miniscript_tests.cpp +8/-7
  • src/test/transaction_tests.cpp +7/-8
  • src/ipc/test/ipc_tests.cpp +7/-6
  • src/test/fuzz/feeratediagram.cpp +5/-7
  • src/ipc/test/fuzz/ipc.cpp +5/-4
  • src/test/blockmanager_tests.cpp +5/-4
  • src/test/fuzz/versionbits.cpp +5/-4
  • src/test/txrequest_tests.cpp +4/-4
  • src/test/validation_tests.cpp +4/-4
  • src/test/crypto_tests.cpp +4/-3
  • src/test/fuzz/base_encode_decode.cpp +3/-4
  • src/test/fuzz/merkle.cpp +4/-3
  • src/test/miniminer_tests.cpp +4/-3
  • src/test/blockencodings_tests.cpp +3/-3
  • src/test/blockfilter_tests.cpp +3/-3
  • src/test/fuzz/feefrac.cpp +4/-2
  • src/test/fuzz/muhash.cpp +4/-2
  • src/test/key_io_tests.cpp +3/-3
  • src/test/validation_chainstatemanager_tests.cpp +3/-3
  • src/test/compress_tests.cpp +3/-2
  • src/test/fuzz/addrman.cpp +3/-2
  • src/test/fuzz/bech32.cpp +3/-2
  • src/test/fuzz/block.cpp +3/-2
  • src/test/fuzz/key.cpp +3/-2
  • src/test/fuzz/key_io.cpp +3/-2
  • src/test/fuzz/locale.cpp +3/-2
  • src/test/fuzz/script.cpp +3/-2
  • src/test/fuzz/string.cpp +3/-2
  • src/test/fuzz/transaction.cpp +3/-2
  • src/test/fuzz/util/mempool.cpp +3/-2
  • src/test/headers_sync_chainwork_tests.cpp +3/-2
  • src/test/logging_tests.cpp +3/-2
  • src/test/mempool_tests.cpp +3/-2
  • src/test/node_init_tests.cpp +3/-2
  • src/test/orphanage_tests.cpp +3/-2
  • src/test/rbf_tests.cpp +3/-2
  • src/test/sigopcount_tests.cpp +3/-2
  • src/test/txdownload_tests.cpp +3/-2
  • src/wallet/test/ismine_tests.cpp +3/-2
  • src/test/fuzz/asmap.cpp +3/-1
  • src/test/fuzz/asmap_direct.cpp +2/-2
  • src/test/fuzz/bitdeque.cpp +3/-1
  • src/test/fuzz/bitset.cpp +3/-1
  • src/test/fuzz/fees.cpp +3/-1
  • src/test/fuzz/headerssync.cpp +3/-1
  • src/test/fuzz/miniscript.cpp +3/-1
  • src/test/fuzz/net.cpp +3/-1
  • src/test/fuzz/private_broadcast.cpp +3/-1
  • src/test/fuzz/txdownloadman.cpp +3/-1
  • src/test/fuzz/txgraph.cpp +3/-1
  • src/test/fuzz/txrequest.cpp +3/-1
  • src/test/fuzz/vecdeque.cpp +3/-1
  • src/test/private_broadcast_tests.cpp +3/-1
  • src/test/util/chainstate.h +2/-2
  • src/test/util/net.h +2/-2
  • src/test/util/transaction_utils.cpp +3/-1
  • src/test/util_tests.cpp +2/-2
  • src/wallet/test/coinselector_tests.cpp +3/-1
  • src/wallet/test/fuzz/coincontrol.cpp +3/-1
  • src/wallet/test/fuzz/coinselection.cpp +3/-1
  • src/wallet/test/fuzz/spend.cpp +3/-1
  • src/wallet/test/util.cpp +2/-2
  • src/qt/test/apptests.cpp +2/-1
  • src/test/fuzz/banman.cpp +2/-1
  • src/test/fuzz/difference_formatter.cpp +2/-1
  • src/test/fuzz/flatfile.cpp +2/-1
  • src/test/fuzz/net_permissions.cpp +2/-1
  • src/test/fuzz/netaddress.cpp +2/-1
  • src/test/fuzz/threadpool.cpp +2/-1
  • src/test/fuzz/util/wallet.h +2/-1
  • src/test/interfaces_tests.cpp +2/-1
  • src/test/pcp_tests.cpp +2/-1
  • src/test/scriptnum10.h +2/-1
  • src/test/txvalidation_tests.cpp +2/-1
  • src/wallet/test/wallet_test_fixture.cpp +2/-1
  • src/test/fuzz/bip324.cpp +2/-0
  • src/test/fuzz/block_header.cpp +1/-1
  • src/test/fuzz/bloom_filter.cpp +1/-1
  • src/test/fuzz/cluster_linearize.cpp +2/-0
  • src/test/fuzz/coins_view.cpp +1/-1
  • src/test/fuzz/coinscache_sim.cpp +1/-1
  • src/test/fuzz/crypto_aes256.cpp +1/-1
  • src/test/fuzz/crypto_aes256cbc.cpp +1/-1
  • src/test/fuzz/crypto_common.cpp +1/-1
  • src/test/fuzz/cuckoocache.cpp +2/-0
  • src/test/fuzz/decode_tx.cpp +1/-1
  • src/test/fuzz/float.cpp +1/-1
  • src/test/fuzz/golomb_rice.cpp +1/-1
  • src/test/fuzz/hex.cpp +1/-1
  • src/test/fuzz/http_request.cpp +1/-1
  • src/test/fuzz/message.cpp +1/-1
  • src/test/fuzz/node_eviction.cpp +1/-1
  • src/test/fuzz/p2p_transport_serialization.cpp +1/-1
  • src/test/fuzz/parse_hd_keypath.cpp +1/-1
  • src/test/fuzz/parse_iso8601.cpp +1/-1
  • src/test/fuzz/parse_numbers.cpp +1/-1
  • src/test/fuzz/prevector.cpp +2/-0
  • src/test/fuzz/rolling_bloom_filter.cpp +1/-1
  • src/test/fuzz/rpc.cpp +1/-1
  • src/test/fuzz/script_flags.cpp +1/-1
  • src/test/fuzz/script_sign.cpp +1/-1
  • src/test/fuzz/scriptnum_ops.cpp +1/-1
  • src/test/fuzz/util/net.cpp +1/-1
  • src/test/random_tests.cpp +1/-1
  • src/test/sock_tests.cpp +1/-1
  • src/wallet/test/group_outputs_tests.cpp +1/-1
  • src/test/blockchain_tests.cpp +1/-0
  • src/test/btcsignals_tests.cpp +1/-0
  • src/test/chainstate_write_tests.cpp +1/-0
  • src/test/checkqueue_tests.cpp +1/-0
  • src/test/cuckoocache_tests.cpp +1/-0
  • src/test/flatfile_tests.cpp +1/-0
  • src/test/fuzz/addition_overflow.cpp +1/-0
  • src/test/fuzz/block_index.cpp +1/-0
  • src/test/fuzz/block_index_tree.cpp +1/-0
  • src/test/fuzz/connect_block.cpp +1/-0
  • src/test/fuzz/connman.cpp +1/-0
  • src/test/fuzz/crypto_chacha20.cpp +1/-0
  • src/test/fuzz/crypto_chacha20poly1305.cpp +1/-0
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp +1/-0
  • src/test/fuzz/crypto_poly1305.cpp +1/-0
  • src/test/fuzz/dbwrapper.cpp +0/-1
  • src/test/fuzz/descriptor_parse.cpp +1/-0
  • src/test/fuzz/deserialize.cpp +1/-0
  • src/test/fuzz/fee_rate.cpp +1/-0
  • src/test/fuzz/integer.cpp +0/-1
  • src/test/fuzz/kitchen_sink.cpp +1/-0
  • src/test/fuzz/multiplication_overflow.cpp +1/-0
  • src/test/fuzz/netbase_dns_lookup.cpp +1/-0
  • src/test/fuzz/p2p_headers_presync.cpp +1/-0
  • src/test/fuzz/p2p_private_broadcast.cpp +1/-0
  • src/test/fuzz/poolresource.cpp +1/-0
  • src/test/fuzz/primitives_transaction.cpp +1/-0
  • src/test/fuzz/script_descriptor_cache.cpp +1/-0
  • src/test/fuzz/secp256k1_ec_seckey_import_export_der.cpp +1/-0
  • src/test/fuzz/span.cpp +0/-1
  • src/test/fuzz/tx_in.cpp +0/-1
  • src/test/fuzz/tx_out.cpp +1/-0
  • src/test/fuzz/util.h +1/-0
  • src/test/httpserver_tests.cpp +1/-0
  • src/test/mempool_fee_estimator_tests.cpp +1/-0
  • src/test/net_tests.cpp +1/-0
  • src/test/scheduler_tests.cpp +1/-0
  • src/test/streams_tests.cpp +1/-0
  • src/test/threadpool_tests.cpp +1/-0
  • src/test/util/cluster_linearize.h +1/-0
  • src/test/util/net.cpp +1/-0
  • src/test/util/poolresourcetester.h +0/-1
  • src/wallet/test/fuzz/wallet_bdb_parser.cpp +1/-0
  • src/wallet/test/psbt_wallet_tests.cpp +1/-0
  • src/wallet/test/spend_tests.cpp +1/-0

Card

PR 36074 performs a mechanical scripted diff across test, bench, and fuzz harnesses to add #include <util/check.h> wherever assertions are used and removes redundant <cassert> includes. It aims to clarify assertion semantics and aid IWYU tooling. The change is currently in draft and dirty, conflicting with dozens of PRs, leading the author to note that conflict volume may prevent it from merging. Review feedback has been constructive regarding linter regex details.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:57, confidence high, input hash 1bfc2a9891a694db