Skip to content

Commit f0eecf5

Browse files
committed
scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB
Since we have a mockable wallet database, we don't really need to be using BDB or SQLite's in-memory database capabilities. It doesn't really help us to be using those as we aren't doing anything that requires one type of db over the other, and will just prefer SQLite if it's available. MockableDatabase is suitable for these uses, so use CreateMockableWalletDatabase to use that. -BEGIN VERIFY SCRIPT- sed -i "s/CreateMockWalletDatabase(options)/CreateMockableWalletDatabase()/" $(git grep -l "CreateMockWalletDatabase(options)" -- ":(exclude)src/wallet/walletdb.*") sed -i "s/CreateMockWalletDatabase/CreateMockableWalletDatabase/" $(git grep -l "CreateMockWalletDatabase" -- ":(exclude)src/wallet/walletdb.*") -END VERIFY SCRIPT-
1 parent 075962b commit f0eecf5

11 files changed

+19
-19
lines changed

src/bench/wallet_balance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <optional>
1616

1717
using wallet::CWallet;
18-
using wallet::CreateMockWalletDatabase;
18+
using wallet::CreateMockableWalletDatabase;
1919
using wallet::DBErrors;
2020
using wallet::GetBalance;
2121
using wallet::WALLET_FLAG_DESCRIPTORS;
@@ -28,7 +28,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
2828

2929
const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
3030

31-
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
31+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
3232
{
3333
LOCK(wallet.cs_wallet);
3434
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/bench/wallet_create_tx.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <wallet/wallet.h>
1616

1717
using wallet::CWallet;
18-
using wallet::CreateMockWalletDatabase;
18+
using wallet::CreateMockableWalletDatabase;
1919
using wallet::DBErrors;
2020
using wallet::WALLET_FLAG_DESCRIPTORS;
2121

@@ -83,7 +83,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
8383
{
8484
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
8585

86-
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
86+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
8787
{
8888
LOCK(wallet.cs_wallet);
8989
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -136,7 +136,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
136136
static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType>& output_type)
137137
{
138138
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
139-
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
139+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
140140
{
141141
LOCK(wallet.cs_wallet);
142142
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/bench/wallet_loading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
7171
options.create_flags = WALLET_FLAG_DESCRIPTORS;
7272
options.require_format = DatabaseFormat::SQLITE;
7373
}
74-
auto database = CreateMockWalletDatabase(options);
74+
auto database = CreateMockableWalletDatabase();
7575
auto wallet = BenchLoadWallet(std::move(database), context, options);
7676

7777
// Generate a bunch of transactions and addresses to put into the wallet

src/qt/test/addressbooktests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
using wallet::AddWallet;
3434
using wallet::CWallet;
35-
using wallet::CreateMockWalletDatabase;
35+
using wallet::CreateMockableWalletDatabase;
3636
using wallet::RemoveWallet;
3737
using wallet::WALLET_FLAG_DESCRIPTORS;
3838
using wallet::WalletContext;
@@ -76,7 +76,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
7676
auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args));
7777
test.m_node.wallet_loader = wallet_loader.get();
7878
node.setContext(&test.m_node);
79-
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
79+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
8080
wallet->LoadWallet();
8181
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
8282
{

src/qt/test/wallettests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
using wallet::AddWallet;
4949
using wallet::CWallet;
50-
using wallet::CreateMockWalletDatabase;
50+
using wallet::CreateMockableWalletDatabase;
5151
using wallet::RemoveWallet;
5252
using wallet::WALLET_FLAG_DESCRIPTORS;
5353
using wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS;
@@ -190,7 +190,7 @@ void SyncUpWallet(const std::shared_ptr<CWallet>& wallet, interfaces::Node& node
190190

191191
std::shared_ptr<CWallet> SetupLegacyWatchOnlyWallet(interfaces::Node& node, TestChain100Setup& test)
192192
{
193-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
193+
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
194194
wallet->LoadWallet();
195195
{
196196
LOCK(wallet->cs_wallet);
@@ -208,7 +208,7 @@ std::shared_ptr<CWallet> SetupLegacyWatchOnlyWallet(interfaces::Node& node, Test
208208

209209
std::shared_ptr<CWallet> SetupDescriptorsWallet(interfaces::Node& node, TestChain100Setup& test)
210210
{
211-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
211+
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
212212
wallet->LoadWallet();
213213
LOCK(wallet->cs_wallet);
214214
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/wallet/test/coinselector_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ inline std::vector<OutputGroup>& KnapsackGroupOutputs(const CoinsResult& availab
177177

178178
static std::unique_ptr<CWallet> NewWallet(const node::NodeContext& m_node, const std::string& wallet_name = "")
179179
{
180-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), wallet_name, CreateMockWalletDatabase());
180+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), wallet_name, CreateMockableWalletDatabase());
181181
BOOST_CHECK(wallet->LoadWallet() == DBErrors::LOAD_OK);
182182
LOCK(wallet->cs_wallet);
183183
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/wallet/test/group_outputs_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int nextLockTime = 0;
1818

1919
static std::shared_ptr<CWallet> NewWallet(const node::NodeContext& m_node)
2020
{
21-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
21+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
2222
wallet->LoadWallet();
2323
LOCK(wallet->cs_wallet);
2424
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/wallet/test/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace wallet {
1818
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key)
1919
{
20-
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockWalletDatabase());
20+
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockableWalletDatabase());
2121
{
2222
LOCK2(wallet->cs_wallet, ::cs_main);
2323
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
@@ -47,7 +47,7 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
4747

4848
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database, DatabaseOptions& options)
4949
{
50-
auto new_database = CreateMockWalletDatabase(options);
50+
auto new_database = CreateMockableWalletDatabase();
5151

5252
// Get a cursor to the original database
5353
auto batch = database.MakeBatch();

src/wallet/test/wallet_test_fixture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace wallet {
1111
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
1212
: TestingSetup(chainName),
1313
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
14-
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
14+
m_wallet(m_node.chain.get(), "", CreateMockableWalletDatabase())
1515
{
1616
m_wallet.LoadWallet();
1717
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
119119
// Verify ScanForWalletTransactions picks up transactions in both the old
120120
// and new block files.
121121
{
122-
CWallet wallet(m_node.chain.get(), "", CreateMockWalletDatabase());
122+
CWallet wallet(m_node.chain.get(), "", CreateMockableWalletDatabase());
123123
{
124124
LOCK(wallet.cs_wallet);
125125
LOCK(Assert(m_node.chainman)->GetMutex());

0 commit comments

Comments
 (0)