mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-14 23:37:51 +02:00
test: Unroll && conditions in macros
Using `&&` in `BOOST_CHECK` is problematic as failures will not indicate which condition failed. By unrolling these checks, the user knows exactly which expression is the failing case. As an example, here is a line that would be particularly hard to debug if it failed: ``` src/test/net_tests.cpp BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "headers" && std::ranges::equal((*ret)[1]->m_recv, MakeByteSpan(msg_data_2))); ``` If any one of these conditions fail, the whole expression fails, with no values printed or indication as to which condition failed. This is also required when using test macros that support value decomposition, which requires `&&` and `||` are `delete`. Examples include `BOOST_TEST`, doctest, Catch2, etc. ref: https://catch2-temp.readthedocs.io/en/latest/assertions.html#other-limitations ref: https://fekir.info/post/decomposing-an-expression/
This commit is contained in:
@@ -1161,7 +1161,8 @@ BOOST_AUTO_TEST_CASE(package_rbf_tests)
|
||||
child_key, child_spk, coinbase_value - 199 - 1300, /*submit=*/false));
|
||||
|
||||
// In all packages, the parents conflict with each other
|
||||
BOOST_CHECK(tx_parent_1->GetHash() != tx_parent_2->GetHash() && tx_parent_2->GetHash() != tx_parent_3->GetHash());
|
||||
BOOST_CHECK(tx_parent_1->GetHash() != tx_parent_2->GetHash());
|
||||
BOOST_CHECK(tx_parent_2->GetHash() != tx_parent_3->GetHash());
|
||||
|
||||
// 1 parent paying 200sat, 1 child paying 200sat.
|
||||
Package package1{tx_parent_1, tx_child_1};
|
||||
|
||||
Reference in New Issue
Block a user