aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-05-10 22:29:17 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-05-20 12:03:22 +0200
commit447761c8228d58f948aae7e73ed079c028cacb97 (patch)
tree138ae285148636dd18870df62338a6acacaa400c /src/test
parent0f8c95dccd120ad5fd371f81025137b855796f13 (diff)
kernel: Add notification interface
This commit is part of the libbitcoinkernel project and seeks to remove the ChainstateManager's and, more generally, the kernel library's dependency on interface_ui with options methods in this and the following few commits. By removing interface_ui from the kernel library, its dependency on boost is reduced to just boost::multi_index. Define a new kernel notification class with virtual methods for notifying about internal kernel events. Create a new file in the node library for defining a function creating the default set of notification methods such that these do not need to be re-defined all over the codebase. As a first step, add a `blockTip` method, wrapping `uiInterface.NotifyBlockTip`.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/util/setup_common.cpp5
-rw-r--r--src/test/validation_chainstatemanager_tests.cpp4
2 files changed, 9 insertions, 0 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index eedb406cbd..8ac17838ac 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -23,6 +23,7 @@
#include <node/blockstorage.h>
#include <node/chainstate.h>
#include <node/context.h>
+#include <node/kernel_notifications.h>
#include <node/mempool_args.h>
#include <node/miner.h>
#include <node/validation_cache_args.h>
@@ -64,6 +65,7 @@ using node::ApplyArgsManOptions;
using node::BlockAssembler;
using node::BlockManager;
using node::CalculateCacheSizes;
+using node::KernelNotifications;
using node::LoadChainstate;
using node::RegenerateCommitments;
using node::VerifyLoadedChainstate;
@@ -182,11 +184,14 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vecto
m_cache_sizes = CalculateCacheSizes(m_args);
+ m_node.notifications = std::make_unique<KernelNotifications>();
+
const ChainstateManager::Options chainman_opts{
.chainparams = chainparams,
.datadir = m_args.GetDataDirNet(),
.adjusted_time_callback = GetAdjustedTime,
.check_block_index = true,
+ .notifications = *m_node.notifications,
};
const BlockManager::Options blockman_opts{
.chainparams = chainman_opts.chainparams,
diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
index 05e2787075..8ca4e62e27 100644
--- a/src/test/validation_chainstatemanager_tests.cpp
+++ b/src/test/validation_chainstatemanager_tests.cpp
@@ -4,6 +4,7 @@
//
#include <chainparams.h>
#include <consensus/validation.h>
+#include <node/kernel_notifications.h>
#include <node/utxo_snapshot.h>
#include <random.h>
#include <rpc/blockchain.h>
@@ -23,6 +24,7 @@
#include <boost/test/unit_test.hpp>
using node::BlockManager;
+using node::KernelNotifications;
using node::SnapshotMetadata;
BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup)
@@ -377,10 +379,12 @@ struct SnapshotTestSetup : TestChain100Setup {
LOCK(::cs_main);
chainman.ResetChainstates();
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 0);
+ m_node.notifications = std::make_unique<KernelNotifications>();
const ChainstateManager::Options chainman_opts{
.chainparams = ::Params(),
.datadir = m_args.GetDataDirNet(),
.adjusted_time_callback = GetAdjustedTime,
+ .notifications = *m_node.notifications,
};
const BlockManager::Options blockman_opts{
.chainparams = chainman_opts.chainparams,