test: move-only ComputeFilter to src/test/lib/blockfilter

This commit is contained in:
MarcoFalke 2019-09-20 14:02:16 -04:00
parent 341e8d355d
commit fa54b3e248
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
4 changed files with 44 additions and 19 deletions

View file

@ -56,8 +56,10 @@ RAW_TEST_FILES =
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
BITCOIN_TEST_SUITE = \
test/lib/transaction_utils.h \
test/lib/blockfilter.cpp \
test/lib/blockfilter.h \
test/lib/transaction_utils.cpp \
test/lib/transaction_utils.h \
test/main.cpp \
test/setup_common.h \
test/setup_common.cpp

View file

@ -8,8 +8,9 @@
#include <index/blockfilterindex.h>
#include <miner.h>
#include <pow.h>
#include <test/setup_common.h>
#include <script/standard.h>
#include <test/lib/blockfilter.h>
#include <test/setup_common.h>
#include <util/time.h>
#include <validation.h>
@ -17,23 +18,6 @@
BOOST_AUTO_TEST_SUITE(blockfilter_index_tests)
static bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index,
BlockFilter& filter)
{
CBlock block;
if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
return false;
}
CBlockUndo block_undo;
if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
return false;
}
filter = BlockFilter(filter_type, block, block_undo);
return true;
}
static bool CheckFilterLookups(BlockFilterIndex& filter_index, const CBlockIndex* block_index,
uint256& last_header)
{

View file

@ -0,0 +1,26 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/lib/blockfilter.h>
#include <chainparams.h>
#include <validation.h>
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter)
{
CBlock block;
if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
return false;
}
CBlockUndo block_undo;
if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
return false;
}
filter = BlockFilter(filter_type, block, block_undo);
return true;
}

View file

@ -0,0 +1,13 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_LIB_BLOCKFILTER_H
#define BITCOIN_TEST_LIB_BLOCKFILTER_H
#include <blockfilter.h>
class CBlockIndex;
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter);
#endif // BITCOIN_TEST_LIB_BLOCKFILTER_H