mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
refactor: wallet: move error handling to PopulateWalletFromDB()
This commit is contained in:
@@ -306,7 +306,7 @@ void TestLoadWallet(const std::string& name, DatabaseFormat format, std::functio
|
||||
std::vector<bilingual_str> warnings;
|
||||
auto database{MakeWalletDatabase(name, options, status, error)};
|
||||
auto wallet{std::make_shared<CWallet>(chain.get(), "", std::move(database))};
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(), DBErrors::LOAD_OK);
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(error, warnings), DBErrors::LOAD_OK);
|
||||
WITH_LOCK(wallet->cs_wallet, f(wallet));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(wallet_load_descriptors, TestingSetup)
|
||||
{
|
||||
bilingual_str _error;
|
||||
std::vector<bilingual_str> _warnings;
|
||||
std::unique_ptr<WalletDatabase> database = CreateMockableWalletDatabase();
|
||||
{
|
||||
// Write unknown active descriptor
|
||||
@@ -52,7 +54,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_descriptors, TestingSetup)
|
||||
{
|
||||
// Now try to load the wallet and verify the error.
|
||||
const std::shared_ptr<CWallet> wallet(new CWallet(m_node.chain.get(), "", std::move(database)));
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(), DBErrors::UNKNOWN_DESCRIPTOR);
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(_error, _warnings), DBErrors::UNKNOWN_DESCRIPTOR);
|
||||
}
|
||||
|
||||
// Test 2
|
||||
@@ -78,7 +80,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_descriptors, TestingSetup)
|
||||
{
|
||||
// Now try to load the wallet and verify the error.
|
||||
const std::shared_ptr<CWallet> wallet(new CWallet(m_node.chain.get(), "", std::move(database)));
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(), DBErrors::CORRUPT);
|
||||
BOOST_CHECK_EQUAL(wallet->PopulateWalletFromDB(_error, _warnings), DBErrors::CORRUPT);
|
||||
BOOST_CHECK(found); // The error must be logged
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user