test: Remove BOOST_FAIL and add info in descriptor_tests #36772

Manually merged
rustaceanrob merged 1 commit from nov-5-boost-macros into master 2026-11-06 16:51:28 +00:00 AGit
rustaceanrob commented 2026-11-05 10:10:56 +00:00 (Migrated from github.com)

The BOOST_FAIL here is used to exit the test based on a condition, but we can use REQUIRE directly. The context string is only printed on failure to my knowledge and this is not called on a child thread so there is no behavior change.

The descriptor_tests uses BOOST_TEST_INFO to add the descriptor if the next condition fails, but there are some other places that also print the public or private descriptor. Seems useful throughout this whole funciton body to attach the private and public descriptor as context.

Found in #35713 as low usage macros

ref:

The `BOOST_FAIL` here is used to exit the test based on a condition, but we can use `REQUIRE` directly. The context string is only printed on failure to my knowledge and this is not called on a child thread so there is no behavior change. The `descriptor_tests` uses `BOOST_TEST_INFO` to add the descriptor if the next condition fails, but there are some other places that also print the public or private descriptor. Seems useful throughout this whole funciton body to attach the private and public descriptor as context. Found in #35713 as low usage macros ref: - https://www.boost.org/doc/libs/latest/libs/test/doc/html/boost_test/utf_reference/testout_reference/test_output_macro_info.html - https://www.boost.org/doc/libs/latest/libs/test/doc/html/boost_test/utf_reference/testout_reference/test_output_macro_context_sticky.html - https://www.boost.org/doc/libs/latest/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_fail.html
DrahtBot commented 2026-11-05 10:11:05 +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.

Type Reviewers
ACK l0rinc, maflcko, sedited
Stale ACK ismaelsadeeq

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36442 (descriptor: Represent multipath descriptors in a single Descriptor object by achow101)
  • #36013 (test: Descriptor roundtrip and raw()/ addr() coverage by pablomartin4btc)

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/36772 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36772.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36772#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. | Type | Reviewers | | ---- | --------- | | ACK | [l0rinc](https://github.com/bitcoin/bitcoin/pull/36772#issuecomment-6682236347), [maflcko](https://github.com/bitcoin/bitcoin/pull/36772#issuecomment-6687976142), [sedited](https://github.com/bitcoin/bitcoin/pull/36772#pullrequestreview-5803710277) | | Stale ACK | [ismaelsadeeq](https://github.com/bitcoin/bitcoin/pull/36772#pullrequestreview-5783725069) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36442](https://github.com/bitcoin/bitcoin/pull/36442) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36442.svg"></sub> (descriptor: Represent multipath descriptors in a single Descriptor object by achow101) * [#36013](https://github.com/bitcoin/bitcoin/pull/36013) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36013.svg"></sub> (test: Descriptor roundtrip and raw()/ addr() coverage by pablomartin4btc) 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

🔵 Suggestion · Descriptor test context hides the apostrophe-to-h pass

Failures relying on the new scoped context show the original apostrophe form even during the converted h pass, losing diagnostic detail previously supplied by the removed messages.

Location: src/test/descriptor_tests.cpp:186 (head).

Review coverage was incomplete.


Reviewed: f5a887c19961 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:46258b7e3da9f8fbea859823935205bab918d5aa117e411e18dcda4c5d5077d6:b3906d5974a831cf25d9d4076421aeb88934ca1265895f22224d53119372abb5 --> <!-- ralph-base:f22abab451b6c2327308df832246b2cba9c35658 --> <!-- ralph-head:f5a887c199613be9ddc8a13fbb7934af614fa579 --> <!-- ralph-case:8394329686e4852d111dbc27dc0b205897989cc8ec2bd3cb214cd954944f678d --> **🔵 Suggestion · Descriptor test context hides the apostrophe-to-h pass** Failures relying on the new scoped context show the original apostrophe form even during the converted `h` pass, losing diagnostic detail previously supplied by the removed messages. Location: [`src/test/descriptor_tests.cpp:186`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/f5a887c199613be9ddc8a13fbb7934af614fa579/src/test/descriptor_tests.cpp#L186>) (head). Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`f5a887c19961`](<https://git.fish.foo/bitcoin/bitcoin/commit/f5a887c199613be9ddc8a13fbb7934af614fa579>) · [Full review report](<https://review.fish.foo/traces/36772-f5a887c199613be9ddc8a13fbb7934af614fa579-2295-2.html>) · [Previous reports](<https://review.fish.foo/traces/36772/>) [permalink](<https://review.fish.foo/traces/36772-f5a887c199613be9ddc8a13fbb7934af614fa579-2295-2.html>)
ismaelsadeeq (Migrated from github.com) reviewed 2026-11-05 10:53:20 +00:00
ismaelsadeeq (Migrated from github.com) left a comment

ACK 6fe87a36e7

Seems fine to change BOOST_FAIL to BOOST_REQUIRE_MESSAGE.

I think the BOOST_TEST_INFO addition is not necessary, but also won't hurt so fine with me.

ACK 6fe87a36e7d23a50b1155bc267786985acf23d5a Seems fine to change `BOOST_FAIL` to `BOOST_REQUIRE_MESSAGE`. I think the `BOOST_TEST_INFO` addition is not necessary, but also won't hurt so fine with me.
l0rinc (Migrated from github.com) requested changes 2026-11-05 11:01:47 +00:00
l0rinc (Migrated from github.com) left a comment

Left a few suggestions to extend descriptor context to the parsing checks and simplify assertions.

Left a few suggestions to extend descriptor context to the parsing checks and simplify assertions.
l0rinc (Migrated from github.com) commented 2026-11-05 10:51:38 +00:00

Changing BOOST_CHECK_MESSAGE to remove failure context is surprising in a PR framed around removing BOOST_FAIL and adding info.

To include the parsing checks in the context too, we could wrap the whole DoCheck body in BOOST_TEST_CONTEXT("Priv desc: " << prv, "Pub desc: " << pub).

Changing `BOOST_CHECK_MESSAGE` to remove failure context is surprising in a PR framed around removing `BOOST_FAIL` and adding info. To include the parsing checks in the context too, we could wrap the whole `DoCheck` body in `BOOST_TEST_CONTEXT("Priv desc: " << prv, "Pub desc: " << pub)`.
l0rinc (Migrated from github.com) commented 2026-11-05 10:52:13 +00:00

The message now just restates the assertion. We could use a conditional BOOST_CHECK_EQUAL instead:

-    BOOST_CHECK_MESSAGE(is_combo || parse_priv->ScriptSize() == scripts[0][0].size() / 2, "Invalid ScriptSize()");
+    if (!is_combo) BOOST_CHECK_EQUAL(parse_priv->ScriptSize().value(), scripts[0][0].size() / 2);

(.value() also makes a missing size fail explicitly.)

The message now just restates the assertion. We could use a conditional `BOOST_CHECK_EQUAL` instead: ```diff - BOOST_CHECK_MESSAGE(is_combo || parse_priv->ScriptSize() == scripts[0][0].size() / 2, "Invalid ScriptSize()"); + if (!is_combo) BOOST_CHECK_EQUAL(parse_priv->ScriptSize().value(), scripts[0][0].size() / 2); ``` (`.value()` also makes a missing size fail explicitly.)
l0rinc (Migrated from github.com) commented 2026-11-05 10:56:00 +00:00

Wouldn't BOOST_CHECK_NE be simpler here?

Wouldn't `BOOST_CHECK_NE` be simpler here?
rustaceanrob (Migrated from github.com) reviewed 2026-11-05 11:10:32 +00:00
rustaceanrob (Migrated from github.com) commented 2026-11-05 11:10:32 +00:00

These are in the scope of BOOST_TEST_INFO_SCOPE above so both descriptors are printed on failure. The prv addition would be redundant in this line but I can move the INFO_SCOPE above the Parse if you prefer.

These are in the scope of `BOOST_TEST_INFO_SCOPE` above so both descriptors are printed on failure. The `prv` addition would be redundant in this line but I can move the `INFO_SCOPE` above the `Parse` if you prefer.
rustaceanrob (Migrated from github.com) reviewed 2026-11-05 11:25:10 +00:00
rustaceanrob (Migrated from github.com) commented 2026-11-05 11:25:10 +00:00

The ! is implicitly casting the int to a bool on the RHS so removing !(...) and using NE doesn't have the same behavior if I replaced it with flags & SIGNABLE_FAILS. I can replace it with bool(flags & SIGNABLE_FAILS) to use NE but not sure if that makes things any simpler

The `!` is implicitly casting the `int` to a bool on the RHS so removing `!(...)` and using `NE` doesn't have the same behavior if I replaced it with `flags & SIGNABLE_FAILS`. I can replace it with `bool(flags & SIGNABLE_FAILS)` to use `NE` but not sure if that makes things any simpler
l0rinc (Migrated from github.com) approved these changes 2026-11-06 09:40:33 +00:00
l0rinc (Migrated from github.com) left a comment

ACK 6fe87a36e7

My previous quick review turned out to be a bit shallow: the new scoped context correctly covers the removed failure info. The ScriptSize() suggestion still stands, but it's just a nit. If you touch this again, moving INFO_SCOPE above the Parse calls would be useful too, though the current version already preserves the existing failure context.

ACK 6fe87a36e7d23a50b1155bc267786985acf23d5a My previous quick review turned out to be a bit shallow: the new scoped context correctly covers the removed failure info. [The `ScriptSize()` suggestion](https://github.com/bitcoin/bitcoin/pull/36772/changes#r4479530524) still stands, but it's just a nit. If you touch this again, moving `INFO_SCOPE` above the `Parse` calls would be useful too, though the current version already preserves the existing failure context.
l0rinc (Migrated from github.com) commented 2026-11-06 08:58:12 +00:00

You're right, having clean bools on both sides is simpler, please resolve

You're right, having clean bools on both sides is simpler, please resolve
rustaceanrob (Migrated from github.com) reviewed 2026-11-06 09:54:17 +00:00
rustaceanrob (Migrated from github.com) commented 2026-11-06 09:54:17 +00:00

Took that thanks

Took that thanks
rustaceanrob commented 2026-11-06 09:55:07 +00:00 (Migrated from github.com)

f5a887c199 moved above parse, also suggestions either resolved or taken

f5a887c199613be9ddc8a13fbb7934af614fa579 moved above parse, also suggestions either resolved or taken
l0rinc commented 2026-11-06 10:01:10 +00:00 (Migrated from github.com)
ACK f5a887c199613be9ddc8a13fbb7934af614fa579
maflcko commented 2026-11-06 15:04:29 +00:00 (Migrated from github.com)

review ACK f5a887c199 🎲

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK f5a887c199613be9ddc8a13fbb7934af614fa579 🎲
o1VDtiDphvH08yY3jf1qVaHoUQNhD/jAKGX0ikHPIGhxeItcSia95ZWjnYQ0v7I1dI2naxv+khSmCjObOn3aAg==
review ACK f5a887c199613be9ddc8a13fbb7934af614fa579 🎲 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK f5a887c199613be9ddc8a13fbb7934af614fa579 🎲 o1VDtiDphvH08yY3jf1qVaHoUQNhD/jAKGX0ikHPIGhxeItcSia95ZWjnYQ0v7I1dI2naxv+khSmCjObOn3aAg== ``` </details>
sedited (Migrated from github.com) approved these changes 2026-11-06 16:47:01 +00:00
sedited (Migrated from github.com) left a comment
ACK f5a887c1996
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!36772
No description provided.