Bitcoin Core 29.99.0
P2P Digital Currency
node_init_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2025 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <init.h>
6#include <interfaces/init.h>
7#include <rpc/server.h>
8
9#include <boost/test/unit_test.hpp>
11
13
15
16
17class TestInit : public interfaces::Init
18{
19public:
21 {
23 m_node.init = this;
24 }
25 std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
26 std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
27 {
28 return MakeWalletLoader(chain, *Assert(m_node.args));
29 }
31};
32
34{
35 // Clear state set by BasicTestingSetup that AppInitMain assumes is unset.
38
39 // Prevent the test from trying to listen on ports 8332 and 8333.
40 m_node.args->ForceSetArg("-server", "0");
41 m_node.args->ForceSetArg("-listen", "0");
42
43 // Run through initialization and shutdown code.
49}
50
node::NodeContext m_node
Definition: bitcoin-gui.cpp:42
Interrupt(node)
Shutdown(node)
#define Assert(val)
Identity function.
Definition: check.h:106
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: args.cpp:546
void SetConfigFilePath(fs::path)
Definition: args.cpp:776
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition: logging.cpp:98
Remote init class.
Definition: ipc_test.cpp:28
TestInit(NodeContext &node)
NodeContext & m_node
std::unique_ptr< interfaces::WalletLoader > makeWalletLoader(interfaces::Chain &chain) override
std::unique_ptr< interfaces::Chain > makeChain() override
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:130
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:31
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
Definition: init.cpp:1180
bool AppInitMain(NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
Definition: init.cpp:1361
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition: init.cpp:208
BCLog::Logger & LogInstance()
Definition: logging.cpp:26
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:60
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:989
Definition: messages.h:20
BOOST_AUTO_TEST_CASE(init_test)
#define BOOST_CHECK(expr)
Definition: object.cpp:17
Basic testing setup.
Definition: setup_common.h:64
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
ArgsManager * args
Definition: context.h:74
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:61