Skip to content

Commit c7efb65

Browse files
committed
blockfilter: Update BIP 158 test vectors.
New tests for the case of non-standard OP_RETURN outputs.
1 parent 19308c9 commit c7efb65

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/test/blockfilter_tests.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(gcsfilter_default_constructor)
5454

5555
BOOST_AUTO_TEST_CASE(blockfilter_basic_test)
5656
{
57-
CScript included_scripts[5], excluded_scripts[3];
57+
CScript included_scripts[5], excluded_scripts[4];
5858

5959
// First two are outputs on a single transaction.
6060
included_scripts[0] << std::vector<unsigned char>(0, 65) << OP_CHECKSIG;
@@ -73,14 +73,19 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test)
7373
// This script is not related to the block at all.
7474
excluded_scripts[1] << std::vector<unsigned char>(5, 33) << OP_CHECKSIG;
7575

76+
// OP_RETURN is non-standard since it's not followed by a data push, but is still excluded from
77+
// filter.
78+
excluded_scripts[2] << OP_RETURN << OP_4 << OP_ADD << OP_8 << OP_EQUAL;
79+
7680
CMutableTransaction tx_1;
7781
tx_1.vout.emplace_back(100, included_scripts[0]);
7882
tx_1.vout.emplace_back(200, included_scripts[1]);
83+
tx_1.vout.emplace_back(0, excluded_scripts[0]);
7984

8085
CMutableTransaction tx_2;
8186
tx_2.vout.emplace_back(300, included_scripts[2]);
82-
tx_2.vout.emplace_back(0, excluded_scripts[0]);
83-
tx_2.vout.emplace_back(400, excluded_scripts[2]); // Script is empty
87+
tx_2.vout.emplace_back(0, excluded_scripts[2]);
88+
tx_2.vout.emplace_back(400, excluded_scripts[3]); // Script is empty
8489

8590
CBlock block;
8691
block.vtx.push_back(MakeTransactionRef(tx_1));
@@ -90,7 +95,7 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test)
9095
block_undo.vtxundo.emplace_back();
9196
block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(500, included_scripts[3]), 1000, true);
9297
block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(600, included_scripts[4]), 10000, false);
93-
block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(700, excluded_scripts[2]), 100000, false);
98+
block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(700, excluded_scripts[3]), 100000, false);
9499

95100
BlockFilter block_filter(BlockFilterType::BASIC, block, block_undo);
96101
const GCSFilter& filter = block_filter.GetFilter();

0 commit comments

Comments
 (0)