mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
refactor: Move wallet methods out of chain.h and node.h
Add WalletClient interface so node interface is cleaner and don't need wallet-specific methods. The new NodeContext::wallet_client pointer will also be needed to eliminate global wallet variables like ::vpwallets, because createWallet(), loadWallet(), getWallets(), etc methods called by the GUI need a way to get a reference to the list of open wallets if it is no longer a global variable. Also tweaks splash screen registration for load wallet events to be delayed until after wallet client is created.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
|
||||
{
|
||||
m_chain_client = MakeWalletClient(*m_chain, *Assert(m_node.args), {});
|
||||
m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args), {});
|
||||
|
||||
std::string sep;
|
||||
sep += fs::path::preferred_separator;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H
|
||||
|
||||
#include <interfaces/chain.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <node/context.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
@@ -19,7 +20,7 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
||||
fs::path m_cwd;
|
||||
std::map<std::string, fs::path> m_walletdir_path_cases;
|
||||
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
|
||||
std::unique_ptr<interfaces::ChainClient> m_chain_client;
|
||||
std::unique_ptr<interfaces::WalletClient> m_wallet_client;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H
|
||||
|
||||
@@ -15,7 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["default"]);
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
@@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["custom"]);
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
|
||||
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
|
||||
SetWalletDir(m_walletdir_path_cases["nonexistent"]);
|
||||
{
|
||||
ASSERT_DEBUG_LOG("does not exist");
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
|
||||
SetWalletDir(m_walletdir_path_cases["file"]);
|
||||
{
|
||||
ASSERT_DEBUG_LOG("is not a directory");
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
|
||||
SetWalletDir(m_walletdir_path_cases["relative"]);
|
||||
{
|
||||
ASSERT_DEBUG_LOG("is a relative path");
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["trailing"]);
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["trailing2"]);
|
||||
bool result = m_chain_client->verify();
|
||||
bool result = m_wallet_client->verify();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
|
||||
@@ -11,5 +11,5 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
||||
bool fFirstRun;
|
||||
m_wallet.LoadWallet(fFirstRun);
|
||||
m_chain_notifications_handler = m_chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
|
||||
m_chain_client->registerRpcs();
|
||||
m_wallet_client->registerRpcs();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ struct WalletTestingSetup : public TestingSetup {
|
||||
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
|
||||
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
|
||||
std::unique_ptr<interfaces::ChainClient> m_chain_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args), {});
|
||||
std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args), {});
|
||||
CWallet m_wallet;
|
||||
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user