Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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>
12
14
19
21
22
23class TestInit : public interfaces::Init
24{
25public:
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
node::NodeContext m_node
Interrupt(node)
Shutdown(node)
ChainType
Definition chaintype.h:11
#define Assert(val)
Identity function.
Definition check.h:113
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition args.cpp:571
void SetConfigFilePath(fs::path)
Definition args.cpp:801
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition logging.cpp:98
Remote init class.
Definition ipc_test.cpp:34
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:118
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:1207
bool AppInitMain(NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
Definition init.cpp:1421
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition init.cpp:213
BCLog::Logger & LogInstance()
Definition logging.cpp:26
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
BOOST_AUTO_TEST_CASE(init_test)
#define BOOST_CHECK(expr)
Definition object.cpp:16
Basic testing setup.
Like BasicTestingSetup, but using regtest network instead of mainnet.
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
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:73