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:
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.
43 m_node.args->SetConfigFilePath({});
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.
50 TestInit init{m_node};
52 BOOST_CHECK(AppInitMain(m_node));
53 Interrupt(m_node);
54 Shutdown(m_node);
55}
56
Interrupt(node)
Shutdown(node)
ChainType
Definition chaintype.h:11
#define Assert(val)
Identity function.
Definition check.h:113
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
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
BasicTestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
Like BasicTestingSetup, but using regtest network instead of mainnet.