Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
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
16
struct
InitTestSetup
:
BasicTestingSetup
{
17
InitTestSetup
() :
BasicTestingSetup
{
ChainType
::
REGTEST
} {}
18
};
19
20
BOOST_FIXTURE_TEST_SUITE
(node_init_tests,
InitTestSetup
)
21
22
23
class
TestInit
:
public
interfaces::Init
24
{
25
public
:
26
TestInit
(
NodeContext
&
node
) :
m_node
(
node
)
27
{
28
InitContext
(
m_node
);
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
}
36
NodeContext
&
m_node
;
37
};
38
39
BOOST_AUTO_TEST_CASE
(init_test)
40
{
41
// Clear state set by BasicTestingSetup that AppInitMain assumes is unset.
42
LogInstance
().
DisconnectTestLogger
();
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};
51
BOOST_CHECK
(
AppInitInterfaces
(m_node));
52
BOOST_CHECK
(
AppInitMain
(m_node));
53
Interrupt
(m_node);
54
Shutdown
(m_node);
55
}
56
57
BOOST_AUTO_TEST_SUITE_END
()
Interrupt
Interrupt(node)
Shutdown
Shutdown(node)
ChainType
ChainType
Definition
chaintype.h:11
ChainType::REGTEST
@ REGTEST
Definition
chaintype.h:15
Assert
#define Assert(val)
Identity function.
Definition
check.h:113
BCLog::Logger::DisconnectTestLogger
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition
logging.cpp:98
TestInit
Remote init class.
Definition
ipc_test.cpp:34
TestInit::TestInit
TestInit(NodeContext &node)
Definition
node_init_tests.cpp:26
TestInit::m_node
NodeContext & m_node
Definition
node_init_tests.cpp:36
TestInit::makeWalletLoader
std::unique_ptr< interfaces::WalletLoader > makeWalletLoader(interfaces::Chain &chain) override
Definition
node_init_tests.cpp:32
TestInit::makeChain
std::unique_ptr< interfaces::Chain > makeChain() override
Definition
node_init_tests.cpp:31
interfaces::Chain
Definition
chain.h:118
interfaces::Init
Definition
init.h:31
BOOST_FIXTURE_TEST_SUITE
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
AppInitInterfaces
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
Definition
init.cpp:1207
AppInitMain
bool AppInitMain(NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
Definition
init.cpp:1421
InitContext
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition
init.cpp:213
init.h
init.h
LogInstance
BCLog::Logger & LogInstance()
Definition
logging.cpp:26
init
Definition
bitcoin-gui.cpp:17
interfaces::MakeChain
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Definition
interfaces.cpp:1023
node
Definition
messages.h:21
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(init_test)
Definition
node_init_tests.cpp:39
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition
object.cpp:16
server.h
setup_common.h
BasicTestingSetup::BasicTestingSetup
BasicTestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
Definition
setup_common.cpp:113
InitTestSetup
Like BasicTestingSetup, but using regtest network instead of mainnet.
Definition
node_init_tests.cpp:16
InitTestSetup::InitTestSetup
InitTestSetup()
Definition
node_init_tests.cpp:17
node::NodeContext
Definition
context.h:56
common.h
Generated on
for Bitcoin Core by
1.17.0