What changed, and why it matters
This commit only changes test code in Bitcoin Core. It loosens a C++ concept check so more byte-returning types can be tested, switches a test comparison from 'different sizes' to 'different contents', and tightens a range helper to require non-empty ranges. There is no change to production code, consensus logic, networking, or wallet handling, so it does not introduce a security vulnerability.
No security action needed; this is a routine test-maintenance commit. Reviewers may verify the test logic still covers intended kernel handle/serialization invariants.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/test/kernel/test_kernel.cpp. (1) HasToBytes is relaxed from requiring ToBytes() to return std::vector
Changed components
src/test/kernel/test_kernel.cppInspect captured patch +6 / −6
diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp
index 2afc588c..5a380065 100644
--- a/src/test/kernel/test_kernel.cpp
+++ b/src/test/kernel/test_kernel.cpp
@@ -265,9 +265,7 @@ void run_verify_test(
}
template <typename T>
-concept HasToBytes = requires(T t) {
- { t.ToBytes() } -> std::convertible_to<std::vector<std::byte>>;
-};
+concept HasToBytes = requires(T t) { t.ToBytes(); };
template <typename T>
void CheckHandle(T object, T distinct_object)
@@ -277,7 +275,9 @@ void CheckHandle(T object, T distinct_object)
BOOST_CHECK(object.get() != distinct_object.get());
if constexpr (HasToBytes<T>) {
- BOOST_CHECK_NE(object.ToBytes().size(), distinct_object.ToBytes().size());
+ const auto object_bytes = object.ToBytes();
+ const auto distinct_bytes = distinct_object.ToBytes();
+ BOOST_CHECK(!std::ranges::equal(object_bytes, distinct_bytes));
}
// Copy constructor
@@ -321,7 +321,8 @@ void CheckRange(const RangeType& range, size_t expected_size)
using value_type = std::ranges::range_value_t<RangeType>;
BOOST_CHECK_EQUAL(range.size(), expected_size);
- BOOST_CHECK_EQUAL(range.empty(), (expected_size == 0));
+ BOOST_REQUIRE(range.size() > 0); // Some checks below assume a non-empty range
+ BOOST_REQUIRE(!range.empty());
BOOST_CHECK(range.begin() != range.end());
BOOST_CHECK_EQUAL(std::distance(range.begin(), range.end()), static_cast<std::ptrdiff_t>(expected_size));
@@ -332,7 +333,6 @@ void CheckRange(const RangeType& range, size_t expected_size)
BOOST_CHECK_EQUAL(range[i].get(), (*(range.begin() + i)).get());
}
- BOOST_CHECK_NE(range.at(0).get(), range.at(expected_size - 1).get());
BOOST_CHECK_THROW(range.at(expected_size), std::out_of_range);
BOOST_CHECK_EQUAL(range.front().get(), range[0].get());
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.