mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 02:33:07 +02:00
wallet, test: Remove DuplicateMockDatabase
DuplicateMockDatabase is no longer used. Furthermore, as SQLite gets used more as a database and less as a key value store, this function gets more complicated and more bug prone. As the benchmarks now run equivalently quickly with a real database, retaining this duplication function is no longer necessary.
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
#include <streams.h>
|
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <wallet/context.h>
|
#include <wallet/context.h>
|
||||||
@@ -105,27 +104,6 @@ void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
|
|||||||
WaitForDeleteWallet(std::move(wallet));
|
WaitForDeleteWallet(std::move(wallet));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)
|
|
||||||
{
|
|
||||||
std::unique_ptr<DatabaseBatch> batch_orig = database.MakeBatch();
|
|
||||||
std::unique_ptr<DatabaseCursor> cursor_orig = batch_orig->GetNewCursor();
|
|
||||||
|
|
||||||
std::unique_ptr<WalletDatabase> new_db = CreateMockableWalletDatabase();
|
|
||||||
std::unique_ptr<DatabaseBatch> new_db_batch = new_db->MakeBatch();
|
|
||||||
MockableSQLiteBatch* batch_new = dynamic_cast<MockableSQLiteBatch*>(new_db_batch.get());
|
|
||||||
Assert(batch_new);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
DataStream key, value;
|
|
||||||
DatabaseCursor::Status status = cursor_orig->Next(key, value);
|
|
||||||
Assert(status != DatabaseCursor::Status::FAIL);
|
|
||||||
if (status != DatabaseCursor::Status::MORE) break;
|
|
||||||
batch_new->WriteKey(std::move(key), std::move(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new_db;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getnewaddress(CWallet& w)
|
std::string getnewaddress(CWallet& w)
|
||||||
{
|
{
|
||||||
constexpr auto output_type = OutputType::BECH32;
|
constexpr auto output_type = OutputType::BECH32;
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context);
|
|||||||
std::shared_ptr<CWallet> TestLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context);
|
std::shared_ptr<CWallet> TestLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context);
|
||||||
void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet);
|
void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet);
|
||||||
|
|
||||||
// Creates a copy of the provided database
|
|
||||||
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database);
|
|
||||||
|
|
||||||
/** Returns a new encoded destination from the wallet (hardcoded to BECH32) */
|
/** Returns a new encoded destination from the wallet (hardcoded to BECH32) */
|
||||||
std::string getnewaddress(CWallet& w);
|
std::string getnewaddress(CWallet& w);
|
||||||
/** Returns a new destination, of an specific type, from the wallet */
|
/** Returns a new destination, of an specific type, from the wallet */
|
||||||
|
|||||||
Reference in New Issue
Block a user