Bitcoin Core  31.0.0
P2P Digital Currency
node_init_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2025-present 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>
10 #include <test/util/common.h>
11 #include <test/util/setup_common.h>
12 
13 using node::NodeContext;
14 
18 };
19 
21 
22 class TestInit : public interfaces::Init
24 {
25 public:
27  {
29  m_node.init = this;
30  }
31  std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
32  std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
33  {
34  return MakeWalletLoader(chain, *Assert(m_node.args));
35  }
37 };
38 
40 {
41  // Clear state set by BasicTestingSetup that AppInitMain assumes is unset.
44 
45  // Prevent the test from trying to listen on ports 8332 and 8333.
46  m_node.args->ForceSetArg("-server", "0");
47  m_node.args->ForceSetArg("-listen", "0");
48 
49  // Run through initialization and shutdown code.
55 }
56 
BOOST_AUTO_TEST_CASE(init_test)
TestInit(NodeContext &node)
BCLog::Logger & LogInstance()
Definition: logging.cpp:26
node::NodeContext m_node
Definition: bitcoin-gui.cpp:43
Interrupt(node)
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: args.cpp:571
void SetConfigFilePath(fs::path)
Definition: args.cpp:801
Basic testing setup.
Definition: setup_common.h:64
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:59
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
ArgsManager * args
Definition: context.h:74
BOOST_AUTO_TEST_SUITE_END()
bool AppInitMain(NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
Definition: init.cpp:1421
std::unique_ptr< interfaces::WalletLoader > makeWalletLoader(interfaces::Chain &chain) override
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition: logging.cpp:98
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:61
Definition: messages.h:21
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Shutdown(node)
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:117
Remote init class.
Definition: ipc_test.cpp:33
NodeContext & m_node
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
Definition: init.cpp:1207
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition: init.cpp:213
Like BasicTestingSetup, but using regtest network instead of mainnet.
#define Assert(val)
Identity function.
Definition: check.h:113
#define BOOST_CHECK(expr)
Definition: object.cpp:16