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-
This commit is contained in:
1 parent
075962bc25
commit
f0eecf5e40
11 files changed
+19
-19
No files matched your search
@@ -15,7 +15,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
using wallet::CWallet;
|
using wallet::CWallet;
|
||||||
using wallet::CreateMockWalletDatabase;
|
using wallet::CreateMockableWalletDatabase;
|
||||||
using wallet::DBErrors;
|
using wallet::DBErrors;
|
||||||
using wallet::GetBalance;
|
using wallet::GetBalance;
|
||||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||||
@@ -28,7 +28,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
|
|||||||
|
|
||||||
const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
|
const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
|
||||||
|
|
||||||
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
|
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
using wallet::CWallet;
|
using wallet::CWallet;
|
||||||
using wallet::CreateMockWalletDatabase;
|
using wallet::CreateMockableWalletDatabase;
|
||||||
using wallet::DBErrors;
|
using wallet::DBErrors;
|
||||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
|
|||||||
{
|
{
|
||||||
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||||
|
|
||||||
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
|
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
@@ -136,7 +136,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
|
|||||||
static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType>& output_type)
|
static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType>& output_type)
|
||||||
{
|
{
|
||||||
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||||
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
|
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()};
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
|
|||||||
options.create_flags = WALLET_FLAG_DESCRIPTORS;
|
options.create_flags = WALLET_FLAG_DESCRIPTORS;
|
||||||
options.require_format = DatabaseFormat::SQLITE;
|
options.require_format = DatabaseFormat::SQLITE;
|
||||||
}
|
}
|
||||||
auto database = CreateMockWalletDatabase(options);
|
auto database = CreateMockableWalletDatabase();
|
||||||
auto wallet = BenchLoadWallet(std::move(database), context, options);
|
auto wallet = BenchLoadWallet(std::move(database), context, options);
|
||||||
|
|
||||||
// Generate a bunch of transactions and addresses to put into the wallet
|
// Generate a bunch of transactions and addresses to put into the wallet
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using wallet::AddWallet;
|
using wallet::AddWallet;
|
||||||
using wallet::CWallet;
|
using wallet::CWallet;
|
||||||
using wallet::CreateMockWalletDatabase;
|
using wallet::CreateMockableWalletDatabase;
|
||||||
using wallet::RemoveWallet;
|
using wallet::RemoveWallet;
|
||||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||||
using wallet::WalletContext;
|
using wallet::WalletContext;
|
||||||
@@ -76,7 +76,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
|
|||||||
auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args));
|
auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args));
|
||||||
test.m_node.wallet_loader = wallet_loader.get();
|
test.m_node.wallet_loader = wallet_loader.get();
|
||||||
node.setContext(&test.m_node);
|
node.setContext(&test.m_node);
|
||||||
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
|
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
|
||||||
wallet->LoadWallet();
|
wallet->LoadWallet();
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
using wallet::AddWallet;
|
using wallet::AddWallet;
|
||||||
using wallet::CWallet;
|
using wallet::CWallet;
|
||||||
using wallet::CreateMockWalletDatabase;
|
using wallet::CreateMockableWalletDatabase;
|
||||||
using wallet::RemoveWallet;
|
using wallet::RemoveWallet;
|
||||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||||
using wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS;
|
using wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS;
|
||||||
@@ -190,7 +190,7 @@ void SyncUpWallet(const std::shared_ptr<CWallet>& wallet, interfaces::Node& node
|
|||||||
|
|
||||||
std::shared_ptr<CWallet> SetupLegacyWatchOnlyWallet(interfaces::Node& node, TestChain100Setup& test)
|
std::shared_ptr<CWallet> SetupLegacyWatchOnlyWallet(interfaces::Node& node, TestChain100Setup& test)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
|
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
|
||||||
wallet->LoadWallet();
|
wallet->LoadWallet();
|
||||||
{
|
{
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
@@ -208,7 +208,7 @@ std::shared_ptr<CWallet> SetupLegacyWatchOnlyWallet(interfaces::Node& node, Test
|
|||||||
|
|
||||||
std::shared_ptr<CWallet> SetupDescriptorsWallet(interfaces::Node& node, TestChain100Setup& test)
|
std::shared_ptr<CWallet> SetupDescriptorsWallet(interfaces::Node& node, TestChain100Setup& test)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
|
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockableWalletDatabase());
|
||||||
wallet->LoadWallet();
|
wallet->LoadWallet();
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ inline std::vector<OutputGroup>& KnapsackGroupOutputs(const CoinsResult& availab
|
|||||||
|
|
||||||
static std::unique_ptr<CWallet> NewWallet(const node::NodeContext& m_node, const std::string& wallet_name = "")
|
static std::unique_ptr<CWallet> NewWallet(const node::NodeContext& m_node, const std::string& wallet_name = "")
|
||||||
{
|
{
|
||||||
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), wallet_name, CreateMockWalletDatabase());
|
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), wallet_name, CreateMockableWalletDatabase());
|
||||||
BOOST_CHECK(wallet->LoadWallet() == DBErrors::LOAD_OK);
|
BOOST_CHECK(wallet->LoadWallet() == DBErrors::LOAD_OK);
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ static int nextLockTime = 0;
|
|||||||
|
|
||||||
static std::shared_ptr<CWallet> NewWallet(const node::NodeContext& m_node)
|
static std::shared_ptr<CWallet> NewWallet(const node::NodeContext& m_node)
|
||||||
{
|
{
|
||||||
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
|
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
|
||||||
wallet->LoadWallet();
|
wallet->LoadWallet();
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
namespace wallet {
|
namespace wallet {
|
||||||
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key)
|
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key)
|
||||||
{
|
{
|
||||||
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockWalletDatabase());
|
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockableWalletDatabase());
|
||||||
{
|
{
|
||||||
LOCK2(wallet->cs_wallet, ::cs_main);
|
LOCK2(wallet->cs_wallet, ::cs_main);
|
||||||
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
|
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
|
||||||
@@ -47,7 +47,7 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
|
|||||||
|
|
||||||
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database, DatabaseOptions& options)
|
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database, DatabaseOptions& options)
|
||||||
{
|
{
|
||||||
auto new_database = CreateMockWalletDatabase(options);
|
auto new_database = CreateMockableWalletDatabase();
|
||||||
|
|
||||||
// Get a cursor to the original database
|
// Get a cursor to the original database
|
||||||
auto batch = database.MakeBatch();
|
auto batch = database.MakeBatch();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace wallet {
|
|||||||
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
||||||
: TestingSetup(chainName),
|
: TestingSetup(chainName),
|
||||||
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
|
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
|
||||||
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
|
m_wallet(m_node.chain.get(), "", CreateMockableWalletDatabase())
|
||||||
{
|
{
|
||||||
m_wallet.LoadWallet();
|
m_wallet.LoadWallet();
|
||||||
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
|
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
|||||||
// Verify ScanForWalletTransactions picks up transactions in both the old
|
// Verify ScanForWalletTransactions picks up transactions in both the old
|
||||||
// and new block files.
|
// and new block files.
|
||||||
{
|
{
|
||||||
CWallet wallet(m_node.chain.get(), "", CreateMockWalletDatabase());
|
CWallet wallet(m_node.chain.get(), "", CreateMockableWalletDatabase());
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
LOCK(Assert(m_node.chainman)->GetMutex());
|
LOCK(Assert(m_node.chainman)->GetMutex());
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(wallet_load_unknown_descriptor, TestingSetup)
|
BOOST_FIXTURE_TEST_CASE(wallet_load_unknown_descriptor, TestingSetup)
|
||||||
{
|
{
|
||||||
std::unique_ptr<WalletDatabase> database = CreateMockWalletDatabase();
|
std::unique_ptr<WalletDatabase> database = CreateMockableWalletDatabase();
|
||||||
{
|
{
|
||||||
// Write unknown active descriptor
|
// Write unknown active descriptor
|
||||||
WalletBatch batch(*database, false);
|
WalletBatch batch(*database, false);
|
||||||
@@ -84,7 +84,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_verif_crypted_key_checksum, TestingSetup)
|
|||||||
|
|
||||||
{ // Context setup.
|
{ // Context setup.
|
||||||
// Create and encrypt legacy wallet
|
// Create and encrypt legacy wallet
|
||||||
std::shared_ptr<CWallet> wallet(new CWallet(m_node.chain.get(), "", CreateMockWalletDatabase()));
|
std::shared_ptr<CWallet> wallet(new CWallet(m_node.chain.get(), "", CreateMockableWalletDatabase()));
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
auto legacy_spkm = wallet->GetOrCreateLegacyScriptPubKeyMan();
|
auto legacy_spkm = wallet->GetOrCreateLegacyScriptPubKeyMan();
|
||||||
BOOST_CHECK(legacy_spkm->SetupGeneration(true));
|
BOOST_CHECK(legacy_spkm->SetupGeneration(true));
|
||||||
|
|||||||
Reference in new issue
Block a user