Bitcoin Core  24.99.0
P2P Digital Currency
wallet_test_fixture.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2021 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 
6 
7 #include <scheduler.h>
8 
9 namespace wallet {
10 WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
11  : TestingSetup(chainName),
12  m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
13  m_wallet(m_node.chain.get(), "", m_args, CreateMockWalletDatabase())
14 {
16  m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
17  m_wallet_loader->registerRpcs();
18 }
19 
21 {
22  if (m_node.scheduler) m_node.scheduler->stop();
23 }
24 } // namespace wallet
node::NodeContext m_node
Definition: bitcoin-gui.cpp:37
#define Assert(val)
Identity function.
Definition: check.h:74
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:236
DBErrors LoadWallet()
Definition: wallet.cpp:2224
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:62
Definition: node.h:39
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase(DatabaseOptions &options)
Return object for accessing temporary in-memory database.
Definition: walletdb.cpp:1242
ArgsManager args
node::NodeContext m_node
Definition: setup_common.h:84
Testing setup that configures a complete environment.
Definition: setup_common.h:109
std::unique_ptr< CScheduler > scheduler
Definition: context.h:63
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:57
std::unique_ptr< interfaces::WalletLoader > m_wallet_loader
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
WalletTestingSetup(const std::string &chainName=CBaseChainParams::MAIN)
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:521