test: Add check for return type in `HasToBytes` concept
What changed, and why it matters
This commit tightens a test-only C++ concept so that any `ToBytes()` method must return something convertible to a byte span. It is purely a test-code quality improvement and does not change production behavior or fix a security bug.
No security action needed. Treat as normal test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/test/kernel/test_kernel.cpp, the HasToBytes concept is changed from merely requiring that t.ToBytes() is a valid expression to also requiring that the result is std::convertible_to<std::span<const std::byte>>. This is a compile-time test constraint; it affects no runtime code path, no consensus logic, and no network-facing code.
Changed components
src/test/kernel/test_kernel.cppInspect captured patch +3 / −1
diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp
index 5958b8d4..e43954de 100644
--- a/src/test/kernel/test_kernel.cpp
+++ b/src/test/kernel/test_kernel.cpp
@@ -265,7 +265,9 @@ void run_verify_test(
}
template <typename T>
-concept HasToBytes = requires(T t) { t.ToBytes(); };
+concept HasToBytes = requires(T t) {
+ { t.ToBytes() } -> std::convertible_to<std::span<const std::byte>>;
+};
template <typename T>
void CheckHandle(T object, T distinct_object)
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.