Skip to content

Commit fa54b3e

Browse files
author
MarcoFalke
committed
test: move-only ComputeFilter to src/test/lib/blockfilter
1 parent 341e8d3 commit fa54b3e

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

src/Makefile.test.include

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ RAW_TEST_FILES =
5656
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
5757

5858
BITCOIN_TEST_SUITE = \
59-
test/lib/transaction_utils.h \
59+
test/lib/blockfilter.cpp \
60+
test/lib/blockfilter.h \
6061
test/lib/transaction_utils.cpp \
62+
test/lib/transaction_utils.h \
6163
test/main.cpp \
6264
test/setup_common.h \
6365
test/setup_common.cpp

src/test/blockfilter_index_tests.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,16 @@
88
#include <index/blockfilterindex.h>
99
#include <miner.h>
1010
#include <pow.h>
11-
#include <test/setup_common.h>
1211
#include <script/standard.h>
12+
#include <test/lib/blockfilter.h>
13+
#include <test/setup_common.h>
1314
#include <util/time.h>
1415
#include <validation.h>
1516

1617
#include <boost/test/unit_test.hpp>
1718

1819
BOOST_AUTO_TEST_SUITE(blockfilter_index_tests)
1920

20-
static bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index,
21-
BlockFilter& filter)
22-
{
23-
CBlock block;
24-
if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
25-
return false;
26-
}
27-
28-
CBlockUndo block_undo;
29-
if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
30-
return false;
31-
}
32-
33-
filter = BlockFilter(filter_type, block, block_undo);
34-
return true;
35-
}
36-
3721
static bool CheckFilterLookups(BlockFilterIndex& filter_index, const CBlockIndex* block_index,
3822
uint256& last_header)
3923
{

src/test/lib/blockfilter.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <test/lib/blockfilter.h>
6+
7+
#include <chainparams.h>
8+
#include <validation.h>
9+
10+
11+
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter)
12+
{
13+
CBlock block;
14+
if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
15+
return false;
16+
}
17+
18+
CBlockUndo block_undo;
19+
if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
20+
return false;
21+
}
22+
23+
filter = BlockFilter(filter_type, block, block_undo);
24+
return true;
25+
}
26+

src/test/lib/blockfilter.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_TEST_LIB_BLOCKFILTER_H
6+
#define BITCOIN_TEST_LIB_BLOCKFILTER_H
7+
8+
#include <blockfilter.h>
9+
class CBlockIndex;
10+
11+
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter);
12+
13+
#endif // BITCOIN_TEST_LIB_BLOCKFILTER_H

0 commit comments

Comments
 (0)