Changeset View
Changeset View
Standalone View
Standalone View
src/test/validationinterface_tests.cpp
Show All 17 Lines | TestInterface(std::function<void()> on_call = nullptr, | ||||
std::function<void()> on_destroy = nullptr) | std::function<void()> on_destroy = nullptr) | ||||
: m_on_call(std::move(on_call)), m_on_destroy(std::move(on_destroy)) {} | : m_on_call(std::move(on_call)), m_on_destroy(std::move(on_destroy)) {} | ||||
virtual ~TestInterface() { | virtual ~TestInterface() { | ||||
if (m_on_destroy) { | if (m_on_destroy) { | ||||
m_on_destroy(); | m_on_destroy(); | ||||
} | } | ||||
} | } | ||||
void BlockChecked(const CBlock &block, | void BlockChecked(const CBlock &block, | ||||
const CValidationState &state) override { | const BlockValidationState &state) override { | ||||
if (m_on_call) { | if (m_on_call) { | ||||
m_on_call(); | m_on_call(); | ||||
} | } | ||||
} | } | ||||
static void Call() { | static void Call() { | ||||
CBlock block; | CBlock block; | ||||
CValidationState state; | BlockValidationState state; | ||||
GetMainSignals().BlockChecked(block, state); | GetMainSignals().BlockChecked(block, state); | ||||
} | } | ||||
std::function<void()> m_on_call; | std::function<void()> m_on_call; | ||||
std::function<void()> m_on_destroy; | std::function<void()> m_on_destroy; | ||||
}; | }; | ||||
// Regression test to ensure UnregisterAllValidationInterfaces calls don't | // Regression test to ensure UnregisterAllValidationInterfaces calls don't | ||||
// destroy a validation interface while it is being called. Bug: | // destroy a validation interface while it is being called. Bug: | ||||
Show All 18 Lines |