mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-21 03:14:05 +02:00
test: Wrap validation functions with TestChainstateManager
This allows to access them in the fuzz test in the next commit without making them public. Co-authored-by: TheCharlatan <seb.kung@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <test/util/validation.h>
|
||||
|
||||
#include <node/blockstorage.h>
|
||||
#include <util/check.h>
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
@@ -11,6 +12,13 @@
|
||||
|
||||
using kernel::ChainstateRole;
|
||||
|
||||
void TestBlockManager::CleanupForFuzzing()
|
||||
{
|
||||
m_dirty_blockindex.clear();
|
||||
m_dirty_fileinfo.clear();
|
||||
m_blockfile_info.resize(1);
|
||||
}
|
||||
|
||||
void TestChainstateManager::DisableNextWrite()
|
||||
{
|
||||
struct TestChainstate : public Chainstate {
|
||||
@@ -43,3 +51,43 @@ void ValidationInterfaceTest::BlockConnected(
|
||||
{
|
||||
obj.BlockConnected(role, block, pindex);
|
||||
}
|
||||
void TestChainstateManager::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
|
||||
{
|
||||
struct TestChainstate : public Chainstate {
|
||||
void CallInvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
InvalidBlockFound(pindex, state);
|
||||
}
|
||||
};
|
||||
|
||||
static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidBlockFound(pindex, state);
|
||||
}
|
||||
|
||||
void TestChainstateManager::InvalidChainFound(CBlockIndex* pindexNew)
|
||||
{
|
||||
struct TestChainstate : public Chainstate {
|
||||
void CallInvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
InvalidChainFound(pindexNew);
|
||||
}
|
||||
};
|
||||
|
||||
static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidChainFound(pindexNew);
|
||||
}
|
||||
|
||||
CBlockIndex* TestChainstateManager::FindMostWorkChain()
|
||||
{
|
||||
struct TestChainstate : public Chainstate {
|
||||
CBlockIndex* CallFindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
return FindMostWorkChain();
|
||||
}
|
||||
};
|
||||
|
||||
return static_cast<TestChainstate*>(&ActiveChainstate())->CallFindMostWorkChain();
|
||||
}
|
||||
|
||||
void TestChainstateManager::ResetBestInvalid()
|
||||
{
|
||||
m_best_invalid = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user