qa: assert_equal -> assert_true/assert_false #36257

Open
hodlinator wants to merge 6 commits from 2026/09/assert_true into master AGit
hodlinator commented 2026-09-15 07:45:35 +00:00 (Migrated from github.com)

Instead of this in the functional tests:

    assert_equal([long expression pushing next arg to the right], True)
    assert_equal([other long expression pushing next arg to the right], False)

we get:

    assert_true([long expression without arg on the right side..])
    assert_false([other long expression without next arg to the right.])

The main point of this change is that assert_true()/assert_false() reduce cognitive tokens when scanning the code (equals to what...?). (As a consequence, assert_true()/assert_false() are also common in other test frameworks).

assert_equal() continues to be used in cases where we don't compare to boolean literals.

assert_true([expression]) is different from plain assert [expression] in that assert is truthy while assert_true requires boolean True. (assert can also be deactivated when executing Python code in optimized mode (see https://github.com/bitcoin/bitcoin/pull/30529#discussion_r1893029530)).

A smaller scale attempt at introducing assert_true() was originally included in #31874 before being dropped.

Instead of this in the functional tests: ```python assert_equal([long expression pushing next arg to the right], True) assert_equal([other long expression pushing next arg to the right], False) ``` we get: ```python assert_true([long expression without arg on the right side..]) assert_false([other long expression without next arg to the right.]) ``` The main point of this change is that `assert_true()`/`assert_false()` reduce cognitive tokens when scanning the code (equals to *what*...?). (As a consequence, `assert_true()`/`assert_false()` are also common in other test frameworks). `assert_equal()` continues to be used in cases where we don't compare to boolean literals. `assert_true([expression])` is different from plain `assert [expression]` in that `assert` is truthy while `assert_true` requires boolean `True`. (`assert` can also be deactivated when executing Python code in optimized mode (see https://github.com/bitcoin/bitcoin/pull/30529#discussion_r1893029530)). A smaller scale attempt at introducing `assert_true()` was originally included in #31874 before being dropped.
DrahtBot commented 2026-09-15 07:45:44 +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:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36976 (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko)
  • #36969 (net: Warn only once when a proxy or the I2P proxy is unreachable by fjahr)
  • #36968 (test/mutation: check wallet listings and wrapped P2WSH addresses in wallet_migration.py by l0rinc)
  • #36891 (test: fix intermittent failure in p2p_tx_download.py by Crypt-iQ)
  • #36796 (wallet, sqlite: Enable secure_delete by default by achow101)
  • #36648 (descriptor, rpc, wallet: do not echo key material in error messages by fametrano)
  • #36627 (tracing: run USDT tests without BPF privileges by willcl-ark)
  • #36540 (mempool: remove time-based transaction expiry by ismaelsadeeq)
  • #36525 (mining: add Block interface, fix template data race by Sjors)
  • #36482 (wallet: Only broadcast resubmitted transactions that were added to the mempool by achow101)
  • #36402 (refactor: wallet_importdescriptors to separate run_test() contents into specific functions by nebula-21)
  • #35920 (net_processing: Ignore MSG_WITNESS_TX entries from INV messages by ajtowns)
  • #35433 (wallet: deprecate replaceable argument from transaction (and psbt) creation (and modification) RPCs by rkrux)
  • #35377 (wallet: Allow importing of descriptors without private keys when the wallet has the private keys by achow101)
  • #35355 (Use atomics for determining whether trace logging is enabled by ajtowns)
  • #34872 (wallet: fix mixed-input transaction accounting in history RPCs by w0xlt)
  • #34038 (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns)
  • #33922 (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)
  • #33112 (wallet: relax external_signer flag constraints by Sjors)
  • #32857 (wallet: allow skipping script paths by Sjors)
  • #31668 (Added rescan option for import descriptors by saikiran57)
  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
  • #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/36257 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36257.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36257#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: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36976](https://github.com/bitcoin/bitcoin/pull/36976) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36976.svg"></sub> (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko) * [#36969](https://github.com/bitcoin/bitcoin/pull/36969) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36969.svg"></sub> (net: Warn only once when a proxy or the I2P proxy is unreachable by fjahr) * [#36968](https://github.com/bitcoin/bitcoin/pull/36968) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36968.svg"></sub> (test/mutation: check wallet listings and wrapped P2WSH addresses in `wallet_migration.py` by l0rinc) * [#36891](https://github.com/bitcoin/bitcoin/pull/36891) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36891.svg"></sub> (test: fix intermittent failure in p2p_tx_download.py by Crypt-iQ) * [#36796](https://github.com/bitcoin/bitcoin/pull/36796) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36796.svg"></sub> (wallet, sqlite: Enable secure_delete by default by achow101) * [#36648](https://github.com/bitcoin/bitcoin/pull/36648) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36648.svg"></sub> (descriptor, rpc, wallet: do not echo key material in error messages by fametrano) * [#36627](https://github.com/bitcoin/bitcoin/pull/36627) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36627.svg"></sub> (tracing: run USDT tests without BPF privileges by willcl-ark) * [#36540](https://github.com/bitcoin/bitcoin/pull/36540) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36540.svg"></sub> (mempool: remove time-based transaction expiry by ismaelsadeeq) * [#36525](https://github.com/bitcoin/bitcoin/pull/36525) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36525.svg"></sub> (mining: add Block interface, fix template data race by Sjors) * [#36482](https://github.com/bitcoin/bitcoin/pull/36482) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36482.svg"></sub> (wallet: Only broadcast resubmitted transactions that were added to the mempool by achow101) * [#36402](https://github.com/bitcoin/bitcoin/pull/36402) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36402.svg"></sub> (refactor: `wallet_importdescriptors` to separate `run_test()` contents into specific functions by nebula-21) * [#35920](https://github.com/bitcoin/bitcoin/pull/35920) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35920.svg"></sub> (net_processing: Ignore MSG_WITNESS_TX entries from INV messages by ajtowns) * [#35433](https://github.com/bitcoin/bitcoin/pull/35433) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35433.svg"></sub> (wallet: deprecate replaceable argument from transaction (and psbt) creation (and modification) RPCs by rkrux) * [#35377](https://github.com/bitcoin/bitcoin/pull/35377) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35377.svg"></sub> (wallet: Allow importing of descriptors without private keys when the wallet has the private keys by achow101) * [#35355](https://github.com/bitcoin/bitcoin/pull/35355) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35355.svg"></sub> (Use atomics for determining whether trace logging is enabled by ajtowns) * [#34872](https://github.com/bitcoin/bitcoin/pull/34872) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34872.svg"></sub> (wallet: fix mixed-input transaction accounting in history RPCs by w0xlt) * [#34038](https://github.com/bitcoin/bitcoin/pull/34038) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34038.svg"></sub> (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns) * [#33922](https://github.com/bitcoin/bitcoin/pull/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) * [#33112](https://github.com/bitcoin/bitcoin/pull/33112) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33112.svg"></sub> (wallet: relax external_signer flag constraints by Sjors) * [#32857](https://github.com/bitcoin/bitcoin/pull/32857) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32857.svg"></sub> (wallet: allow skipping script paths by Sjors) * [#31668](https://github.com/bitcoin/bitcoin/pull/31668) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31668.svg"></sub> (Added rescan option for import descriptors by saikiran57) * [#27865](https://github.com/bitcoin/bitcoin/pull/27865) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27865.svg"></sub> (wallet: Track no-longer-spendable TXOs separately by achow101) * [#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-->
l0rinc (Migrated from github.com) reviewed 2026-09-15 18:54:35 +00:00
l0rinc (Migrated from github.com) left a comment

I don't mind the change, the only reason I see to use explicit True and False is to flip these after a characterization test - but they could also flip the method name.

Based on https://mirror.b10c.me/bitcoin-bitcoin/34773#discussion_r3009767675 and https://mirror.b10c.me/bitcoin-bitcoin/34773#discussion_r3009771746, @maflcko might be interested.

I don't mind the change, the only reason I see to use explicit `True` and `False` is to flip these after a characterization test - but they could also flip the method name. Based on https://mirror.b10c.me/bitcoin-bitcoin/34773#discussion_r3009767675 and https://mirror.b10c.me/bitcoin-bitcoin/34773#discussion_r3009771746, @maflcko might be interested.
l0rinc (Migrated from github.com) commented 2026-09-15 18:47:44 +00:00

4065d7c qa: Add assert_true() / assert_false():

The first commit introduces dead code; there are no users of the new methods, so I have to go through the next commits to tell if these are fully correct or not.

But even just looking at these, I don't like that they do something other than what they claim: they're not actually asserting True, but rather truthiness, which doesn't seem to be documented here. Maybe renaming to truthy and falsy would be more predictable.

I would also like to see tests added to explain their behavior, since otherwise the actual test cases are the test for the new helper method, and both could be incorrect and we wouldn't know. Just a few simple ones with primitives would suffice.

> [4065d7c](https://github.com/bitcoin/bitcoin/pull/36257/changes/4065d7c607f9ff02e41ce464288639d3d964aaa0) _qa: Add assert_true() / assert_false()_: The first commit introduces dead code; there are no users of the new methods, so I have to go through the next commits to tell if these are fully correct or not. But even just looking at these, I don't like that they do something other than what they claim: they're not actually asserting `True`, but rather truthiness, which doesn't seem to be documented here. Maybe renaming to `truthy` and `falsy` would be more predictable. I would also like to see tests added to explain their behavior, since otherwise the actual test cases are the test for the new helper method, and both could be incorrect and we wouldn't know. Just a few simple ones with primitives would suffice.
hodlinator (Migrated from github.com) reviewed 2026-09-15 20:20:27 +00:00
hodlinator (Migrated from github.com) left a comment

I don't mind the change, the only reason I see to use explicit True and False is to flip these after a characterization test - but they could also flip the method name.

It was reviewing your characterization test flipping which made me flip and implement this. :)

> I don't mind the change, the only reason I see to use explicit `True` and `False` is to flip these after a characterization test - but they could also flip the method name. It was reviewing your characterization test flipping which made me flip and implement this. :)
hodlinator (Migrated from github.com) commented 2026-09-15 20:09:23 +00:00

re https://github.com/bitcoin/bitcoin/pull/36257#discussion_r4019082601:

Thanks for catching the accidental degradation in correctness! I originally used != True/!= False but the ruff linter recommended the truthy/falsy variants. is not seems to fit the bill without angering ruff.

You can patch the test_runner with this and run it to verify the latest push is more correct:

Diff
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -30,6 +30,8 @@ import tempfile
 import re
 import logging
 from test_framework.util import (
+    assert_false,
+    assert_true,
     Binaries,
     export_env_build_path,
     get_binary_paths,
@@ -967,4 +969,52 @@ class RPCCoverage():
 
 
 if __name__ == '__main__':
-    main()
+    assert_false(False)
+    assert_true(True)
+
+    try:
+        assert_false(True)
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_false(True) should raise")
+
+    try:
+        assert_true(False)
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_true(False) should raise")
+
+
+    # Test falsyness
+    try:
+        assert_false(list())
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_false is falsy")
+
+    try:
+        assert_false([1, 2])
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_false is broken")
+
+    # Test truthyness
+    try:
+        assert_true([1, 2])
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_true is truthy")
+
+    try:
+        assert_true(list())
+    except AssertionError:
+        pass
+    else:
+        raise AssertionError("assert_true is broken")
+
+    print("assert_false/assert_true have expected behavior!")

None of the other util methods have these meta-tests AFAIK. If you insist do you have any suggestion for where to start adding them?

Regarding adding them as dead code, it's a natural effect of having to add them before the scripted diff. (Only with the exception of one wallet test in "qa: Fix weird case of 3-arg assert_equal() ahead of scripted diff").

re https://github.com/bitcoin/bitcoin/pull/36257#discussion_r4019082601: Thanks for catching the accidental degradation in correctness! I originally used `!= True`/`!= False` but the ruff linter recommended the truthy/falsy variants. `is not` seems to fit the bill without angering ruff. You can patch the test_runner with this and run it to verify the latest push is more correct: <details><summary>Diff</summary> ```diff --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -30,6 +30,8 @@ import tempfile import re import logging from test_framework.util import ( + assert_false, + assert_true, Binaries, export_env_build_path, get_binary_paths, @@ -967,4 +969,52 @@ class RPCCoverage(): if __name__ == '__main__': - main() + assert_false(False) + assert_true(True) + + try: + assert_false(True) + except AssertionError: + pass + else: + raise AssertionError("assert_false(True) should raise") + + try: + assert_true(False) + except AssertionError: + pass + else: + raise AssertionError("assert_true(False) should raise") + + + # Test falsyness + try: + assert_false(list()) + except AssertionError: + pass + else: + raise AssertionError("assert_false is falsy") + + try: + assert_false([1, 2]) + except AssertionError: + pass + else: + raise AssertionError("assert_false is broken") + + # Test truthyness + try: + assert_true([1, 2]) + except AssertionError: + pass + else: + raise AssertionError("assert_true is truthy") + + try: + assert_true(list()) + except AssertionError: + pass + else: + raise AssertionError("assert_true is broken") + + print("assert_false/assert_true have expected behavior!") ``` </details> None of the other util methods have these meta-tests AFAIK. If you insist do you have any suggestion for where to start adding them? Regarding adding them as dead code, it's a natural effect of having to add them before the scripted diff. (Only with the exception of one wallet test in "qa: Fix weird case of 3-arg assert_equal() ahead of scripted diff").
maflcko commented 2026-09-16 09:19:03 +00:00 (Migrated from github.com)

assert_true([expression]) is different from plain assert [expression] in that the latter can be deactivated when executing Python code in optimized mode (see #30529 (comment)).

This isn't wrong, but seems to be missing the point: The reason why assert_equal with True or False is used is not because assert may dropped (in theory, no one is doing this in practise?), but rather that the assert only checks truthy/falsy states, not type-safe equality.

So the only real remaining motivation for this is to reduce code bloat. No objection, but overall I am ~0 on this.

> `assert_true([expression])` is different from plain `assert [expression]` in that the latter can be deactivated when executing Python code in optimized mode (see [#30529 (comment)](https://github.com/bitcoin/bitcoin/pull/30529#discussion_r1893029530)). This isn't wrong, but seems to be missing the point: The reason why assert_equal with `True` or `False` is used is not because `assert` may dropped (in theory, no one is doing this in practise?), but rather that the assert only checks truthy/falsy states, not type-safe equality. So the only real remaining motivation for this is to reduce code bloat. No objection, but overall I am ~0 on this.
hodlinator commented 2026-09-16 10:06:31 +00:00 (Migrated from github.com)

Thanks for having a look @maflcko. Re-orged the PR desc to add the truthyness nuance of assert and also to make the cognitive part more prominent as the motivation.

Thanks for having a look @maflcko. Re-orged the PR desc to add the truthyness nuance of `assert` and also to make the cognitive part more prominent as the motivation.
DrahtBot commented 2026-09-26 00:51:23 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

Earlier concerns remain unresolved; see the Run archive linked from the Review report.

🔵 Suggestion · assert_true and assert_false omit the checked value from failures

The new functional-test helpers omit the actual value from assertion failures, making unexpected non-boolean results harder to diagnose than with the replaced assert_equal calls.

Location: test/functional/test_framework/util.py:91 (head).

🔵 Suggestion · Import preparation mixes required additions with unrelated formatting

The hand-edited import-preparation commit also moves and reindents existing imports, adding manual comparison work before the scripted conversion.

Location: test/functional/rpc_blockchain.py:58 (commit).

Review coverage was incomplete.


Reviewed: f1196fb0386b · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:6078d7619d5186ecd615b4fba1cf1b16d22c9d25cf1cd924310b09d742a5f32a:8840dde1385add290bcb52883baf7c92fb88c8d4b3f44a65c89994451ae30dac --> <!-- ralph-base:dbe9eacd17ae1cc24581081613123a40b44a9f31 --> <!-- ralph-head:f1196fb0386b076b87bdfe26d6c99ed815973b40 --> <!-- ralph-case:d603fbacd17d6f79d099a23d66713bdcb981f25061949ec6afa6468ef6b4aa0e --> Earlier concerns remain unresolved; see the Run archive linked from the Review report. **🔵 Suggestion · `assert_true` and `assert_false` omit the checked value from failures** The new functional-test helpers omit the actual value from assertion failures, making unexpected non-boolean results harder to diagnose than with the replaced `assert_equal` calls. Location: [`test/functional/test_framework/util.py:91`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/f1196fb0386b076b87bdfe26d6c99ed815973b40/test/functional/test_framework/util.py#L91>) (head). **🔵 Suggestion · Import preparation mixes required additions with unrelated formatting** The hand-edited import-preparation commit also moves and reindents existing imports, adding manual comparison work before the scripted conversion. Location: test/functional/rpc_blockchain.py:58 (commit). Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`f1196fb0386b`](<https://git.fish.foo/bitcoin/bitcoin/commit/f1196fb0386b076b87bdfe26d6c99ed815973b40>) · [Review report](<https://review.fish.foo/report/36257-f1196fb0386b076b87bdfe26d6c99ed815973b40-3023-9.html>) · [Previous reports](<https://review.fish.foo/traces/36257/>) [permalink](<https://review.fish.foo/report/36257-f1196fb0386b076b87bdfe26d6c99ed815973b40-3023-9.html>)
DrahtBot commented 2026-11-02 22:58:56 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
maflcko commented 2026-11-03 08:48:28 +00:00 (Migrated from github.com)

Can you leave this in draft please, while there are reviewed conflicts? Even with review, this isn't going to be merged while it conflicts with real bugfixes. So to avoid wasted review, this should stay in draft while conflicting with reviewed stuff.

Can you leave this in draft please, while there are reviewed conflicts? Even with review, this isn't going to be merged while it conflicts with real bugfixes. So to avoid wasted review, this should stay in draft while conflicting with reviewed stuff.
DrahtBot commented 2026-11-05 12:09:57 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
hodlinator commented 2026-11-09 15:51:03 +00:00 (Migrated from github.com)

Can you leave this in draft please, while there are reviewed conflicts? Even with review, this isn't going to be merged while it conflicts with real bugfixes. So to avoid wasted review, this should stay in draft while conflicting with reviewed stuff.

As stated out of band, my prediction is that if the project continues to be healthy, there will continue to be conflicts until this PR is resolved. If a sufficient number of (stale) ACKs are reached, range-diffing to get 2 fresh ACKs on the same push seems doable, at least with the current approach. Last few rebases I've needed to modify some conflicting import changes and re-run the scripted diff. Running the linters to catch mismatching imports and incorrectly applied scripted diff helps sanity-check new pushes.

> Can you leave this in draft please, while there are reviewed conflicts? Even with review, this isn't going to be merged while it conflicts with real bugfixes. So to avoid wasted review, this should stay in draft while conflicting with reviewed stuff. As stated out of band, my prediction is that if the project continues to be healthy, there will continue to be conflicts until this PR is resolved. If a sufficient number of (stale) ACKs are reached, range-diffing to get 2 fresh ACKs on the same push seems doable, at least with the current approach. Last few rebases I've needed to modify some conflicting import changes and re-run the scripted diff. Running the linters to catch mismatching imports and incorrectly applied scripted diff helps sanity-check new pushes.
maflcko commented 2026-11-16 09:51:26 +00:00 (Migrated from github.com)

Sure, if stuff is free, we could do all of it. However, https://github.com/bitcoin/bitcoin/pull/34395 seems more useful than this and it didn't make it either.

Sure, if stuff is free, we could do all of it. However, https://github.com/bitcoin/bitcoin/pull/34395 seems more useful than this and it didn't make it either.
DrahtBot commented 2026-11-16 10:30:20 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/43847803530/job/133232294579
LLM reason (✨ experimental): CI failed the scripted-diff lint: its guard found existing assert_true/assert_false calls in test/functional.

Hints

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.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/43847803530/job/133232294579</sub> <sub>LLM reason (✨ experimental): CI failed the scripted-diff lint: its guard found existing `assert_true`/`assert_false` calls in `test/functional`.</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>
hodlinator commented 2026-11-16 10:32:25 +00:00 (Migrated from github.com)

Sure, if stuff is free, we could do all of it. However, #34395 seems more useful than this and it didn't make it either.

Agree both are very low-priority, but it seems quite subjective which one is more useful (abbreviating the names of functions vs removing begging-the-question tokens (equals ...to arbitrarily long expression ... False/True)).

Liked how that PR added a guard in the scripted diff against the new names, added a commit here doing the same before introducing the new functions.

> Sure, if stuff is free, we could do all of it. However, #34395 seems more useful than this and it didn't make it either. Agree both are very low-priority, but it seems quite subjective which one is more useful (abbreviating the names of functions vs removing begging-the-question tokens (equals ...to arbitrarily long expression ... `False`/`True`)). Liked how that PR added a guard in the scripted diff against the new names, added a commit here doing the same before introducing the new functions.
DrahtBot commented 2026-11-20 12:55:16 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-23 13:14:09 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
678537201w-art (Migrated from github.com) reviewed 2026-11-24 09:06:45 +00:00
678537201w-art (Migrated from github.com) commented 2026-11-24 09:06:04 +00:00

True

True
hodlinator commented 2026-11-24 09:23:39 +00:00 (Migrated from github.com)

@maflcko I checked your approach in #35139, where you only have ASSERT() rather than ASSERT_TRUE()/ASSERT_FALSE(). One could introduce just one custom non-truthy assert_(arg) function for Python too. The problem with that is I couldn't find a type safe way of negating a boolean aside from also introducing a custom not_(arg) function.

@maflcko I checked your approach in #35139, where you only have `ASSERT()` rather than `ASSERT_TRUE()`/`ASSERT_FALSE()`. One could introduce just one custom *non-truthy* `assert_(arg)` function for Python too. The problem with that is I couldn't find a type safe way of negating a boolean aside from also introducing a custom `not_(arg)` function.
maflcko commented 2026-11-24 09:42:24 +00:00 (Migrated from github.com)

I don't think https://github.com/bitcoin/bitcoin/pull/35139 is going to make it any time soon, it is marked as DRAFT , mostly meant as a tracking issue for the bugs, but maybe I should close it. Also, for reference it has #define ASSERT_EQ(l, r) detail::check_op(l, r, #l " == " #r, "!=", std::equal_to<>{}), not only a single one.

Sure, if stuff is free, we could do all of it. However, #34395 seems more useful than this and it didn't make it either.

Agree both are very low-priority, but it seems quite subjective which one is more useful (abbreviating the names of functions vs removing begging-the-question tokens (equals ...to arbitrarily long expression ... False/True)).

Personally, I sometimes use assert_equal(True, long...expr) ...

I don't think https://github.com/bitcoin/bitcoin/pull/35139 is going to make it any time soon, it is marked as DRAFT , mostly meant as a tracking issue for the bugs, but maybe I should close it. Also, for reference it has `#define ASSERT_EQ(l, r) detail::check_op(l, r, #l " == " #r, "!=", std::equal_to<>{})`, not only a single one. > > Sure, if stuff is free, we could do all of it. However, #34395 seems more useful than this and it didn't make it either. > > Agree both are very low-priority, but it seems quite subjective which one is more useful (abbreviating the names of functions vs removing begging-the-question tokens (equals ...to arbitrarily long expression ... `False`/`True`)). Personally, I sometimes use `assert_equal(True, long...expr)` ...
hodlinator commented 2026-11-24 10:13:47 +00:00 (Migrated from github.com)

Also, for reference it has #define ASSERT_EQ(l, r) detail::check_op(l, r, #l " == " #r, "!=", std::equal_to<>{}), not only a single one.

Yes, I'm all for keeping assert_equal for comparisons against non-literals.

Personally, I sometimes use assert_equal(True, long...expr) ...

One could create a scripted diff for switching existing cases of assert_equal(long...expr, True) to assert_equal(True, long...expr) (not that you have advocated for it). But the current PR approach seems like a better path forward.

> Also, for reference it has `#define ASSERT_EQ(l, r) detail::check_op(l, r, #l " == " #r, "!=", std::equal_to<>{})`, not only a single one. Yes, I'm all for keeping `assert_equal` for comparisons against non-literals. > Personally, I sometimes use `assert_equal(True, long...expr)` ... One could create a scripted diff for switching existing cases of `assert_equal(long...expr, True)` to `assert_equal(True, long...expr)` (not that you have advocated for it). But the current PR approach seems like a better path forward.
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!36257
No description provided.