test: fix scripts in `blockfilter_basic_test`
What changed, and why it matters
This commit fixes a test-only bug in Bitcoin Core's unit tests. The test was accidentally creating empty or wrong-sized data blobs because the arguments to a vector constructor were swapped. This only affects test code, not the live Bitcoin network or wallet software, so it has no security impact on real users.
No action required. This is a test-only fix with no production security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change swaps the arguments to std::vector
Changed components
src/test/blockfilter_tests.cppInspect captured patch +6 / −6
diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp
index 470fdde3..8e21d345 100644
--- a/src/test/blockfilter_tests.cpp
+++ b/src/test/blockfilter_tests.cpp
@@ -59,21 +59,21 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test)
CScript included_scripts[5], excluded_scripts[4];
// First two are outputs on a single transaction.
- included_scripts[0] << std::vector<unsigned char>(0, 65) << OP_CHECKSIG;
- included_scripts[1] << OP_DUP << OP_HASH160 << std::vector<unsigned char>(1, 20) << OP_EQUALVERIFY << OP_CHECKSIG;
+ included_scripts[0] << std::vector<unsigned char>(65, 0) << OP_CHECKSIG;
+ included_scripts[1] << OP_DUP << OP_HASH160 << std::vector<unsigned char>(20, 1) << OP_EQUALVERIFY << OP_CHECKSIG;
// Third is an output on in a second transaction.
- included_scripts[2] << OP_1 << std::vector<unsigned char>(2, 33) << OP_1 << OP_CHECKMULTISIG;
+ included_scripts[2] << OP_1 << std::vector<unsigned char>(33, 2) << OP_1 << OP_CHECKMULTISIG;
// Last two are spent by a single transaction.
- included_scripts[3] << OP_0 << std::vector<unsigned char>(3, 32);
+ included_scripts[3] << OP_0 << std::vector<unsigned char>(32, 3);
included_scripts[4] << OP_4 << OP_ADD << OP_8 << OP_EQUAL;
// OP_RETURN output is an output on the second transaction.
- excluded_scripts[0] << OP_RETURN << std::vector<unsigned char>(4, 40);
+ excluded_scripts[0] << OP_RETURN << std::vector<unsigned char>(40, 4);
// This script is not related to the block at all.
- excluded_scripts[1] << std::vector<unsigned char>(5, 33) << OP_CHECKSIG;
+ excluded_scripts[1] << std::vector<unsigned char>(33, 5) << OP_CHECKSIG;
// OP_RETURN is non-standard since it's not followed by a data push, but is still excluded from
// filter.
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.