mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
test: move-only ComputeFilter to src/test/lib/blockfilter
This commit is contained in:
parent
341e8d355d
commit
fa54b3e248
@ -56,8 +56,10 @@ RAW_TEST_FILES =
|
|||||||
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
|
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
|
||||||
|
|
||||||
BITCOIN_TEST_SUITE = \
|
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.cpp \
|
||||||
|
test/lib/transaction_utils.h \
|
||||||
test/main.cpp \
|
test/main.cpp \
|
||||||
test/setup_common.h \
|
test/setup_common.h \
|
||||||
test/setup_common.cpp
|
test/setup_common.cpp
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
#include <index/blockfilterindex.h>
|
#include <index/blockfilterindex.h>
|
||||||
#include <miner.h>
|
#include <miner.h>
|
||||||
#include <pow.h>
|
#include <pow.h>
|
||||||
#include <test/setup_common.h>
|
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
|
#include <test/lib/blockfilter.h>
|
||||||
|
#include <test/setup_common.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
@ -17,23 +18,6 @@
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(blockfilter_index_tests)
|
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,
|
static bool CheckFilterLookups(BlockFilterIndex& filter_index, const CBlockIndex* block_index,
|
||||||
uint256& last_header)
|
uint256& last_header)
|
||||||
{
|
{
|
||||||
|
26
src/test/lib/blockfilter.cpp
Normal file
26
src/test/lib/blockfilter.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
13
src/test/lib/blockfilter.h
Normal file
13
src/test/lib/blockfilter.h
Normal 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
|
Loading…
Reference in New Issue
Block a user