diff options
author | Andrew Chow <achow101-github@achow101.com> | 2022-04-20 12:51:59 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2022-05-10 11:54:02 -0400 |
commit | a1080802f8d7c3d1251ec6f2be33031f568deafa (patch) | |
tree | 1c3fdcaeeac37f344d11562dccd8c43e07149597 /src/wallet/walletdb.cpp | |
parent | 7c0d34476df446e3825198b27c6f62bba4c0b974 (diff) | |
download | bitcoin-a1080802f8d7c3d1251ec6f2be33031f568deafa.tar.xz |
walletdb: Create a mock database of specific type
We may want to make a mock database of either SQLite or BDB, not just
whatever the compiled default is.
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r-- | src/wallet/walletdb.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 7bbed7973f..26908b3777 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1187,13 +1187,36 @@ std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase() } /** Return object for accessing temporary in-memory database. */ -std::unique_ptr<WalletDatabase> CreateMockWalletDatabase() +std::unique_ptr<WalletDatabase> CreateMockWalletDatabase(DatabaseOptions& options) { - DatabaseOptions options; + + std::optional<DatabaseFormat> format; + if (options.require_format) format = options.require_format; + if (!format) { +#ifdef USE_BDB + format = DatabaseFormat::BERKELEY; +#endif #ifdef USE_SQLITE - return std::make_unique<SQLiteDatabase>("", "", options, true); -#elif USE_BDB + format = DatabaseFormat::SQLITE; +#endif + } + + if (format == DatabaseFormat::SQLITE) { +#ifdef USE_SQLITE + return std::make_unique<SQLiteDatabase>("", "", options, true); +#endif + assert(false); + } + +#ifdef USE_BDB return std::make_unique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), "", options); #endif + assert(false); +} + +std::unique_ptr<WalletDatabase> CreateMockWalletDatabase() +{ + DatabaseOptions options; + return CreateMockWalletDatabase(options); } } // namespace wallet |