suggestion
diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp
--- a/src/test/pmt_tests.cpp
+++ b/src/test/pmt_tests.cpp
@@ -8,4 +8,5 @@
#include <serialize.h>
#include <streams.h>
+#include <test/util/common.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
@@ -143,17 +144,18 @@ BOOST_AUTO_TEST_CASE(pmt_malformed)
// The transaction count is limited to MAX_BLOCK_WEIGHT /
MIN_TRANSACTION_WEIGHT.
- static_assert(MAX_BLOCK_WEIGHT / MIN_TRANSACTION_WEIGHT == 16666);
- BOOST_CHECK(extract(16666, 1, {0x00}) == uint256{1});
- BOOST_CHECK(extract(16667, 1, {0x00}).IsNull());
- // An empty tree is invalid.
+ constexpr uint32_t max_tx_count{MAX_BLOCK_WEIGHT /
MIN_TRANSACTION_WEIGHT};
+ static_assert(max_tx_count == 16666);
+ BOOST_CHECK_EQUAL(extract(max_tx_count, 1, {0x00}), uint256{1});
+ BOOST_CHECK(extract(max_tx_count + 1, 1, {0x00}).IsNull());
+ // An empty tree, more hashes than transactions, and fewer bits than
hashes are
+ // rejected before traversal. Traversal would reject each of them anyway,
so these
+ // check the result, not the early returns.
BOOST_CHECK(extract(0, 0, {0x00}).IsNull());
- // There cannot be more hashes than transactions.
BOOST_CHECK(extract(1, 2, {0x00}).IsNull());
- // There cannot be fewer bits than hashes.
BOOST_CHECK(extract(9, 9, {0xff}).IsNull());
// Traversal runs out of hashes: the root is a parent of a match, so both
of its
// leaves need a hash, but only one is provided.
BOOST_CHECK(extract(2, 1, {0x01}).IsNull());
- // Traversal runs out of bits: eight bits do not cover the path to the
third leaf.
+ // Traversal runs out of bits: eight bits reach the third leaf but not
the fourth.
BOOST_CHECK(extract(16, 8, {0xff}).IsNull());
}