Skip to content

Commit fb0b6ca

Browse files
committed
tests, bench: Remove incorrect LoadWallet() calls
LoadWallet() must only be called immediately after a CWallet is constructed, or not at all. Doing so after any other CWallet member functions have been called may cause pointers and other objects setup by other those functions to become invalidated. Since these tests and benchmarks are using completely new wallets with mock databases, it's not necessary to call LoadWallet() anyways, so these can be dropped.
1 parent 3e69125 commit fb0b6ca

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

src/bench/wallet_create_tx.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
using wallet::CWallet;
1818
using wallet::CreateMockableWalletDatabase;
19-
using wallet::DBErrors;
2019
using wallet::WALLET_FLAG_DESCRIPTORS;
2120

2221
struct TipBlock
@@ -90,7 +89,6 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
9089
LOCK(wallet.cs_wallet);
9190
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
9291
wallet.SetupDescriptorScriptPubKeyMans();
93-
if (wallet.LoadWallet() != DBErrors::LOAD_OK) assert(false);
9492
}
9593

9694
// Generate destinations
@@ -146,7 +144,6 @@ static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType
146144
LOCK(wallet.cs_wallet);
147145
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
148146
wallet.SetupDescriptorScriptPubKeyMans();
149-
if (wallet.LoadWallet() != DBErrors::LOAD_OK) assert(false);
150147
}
151148

152149
// Generate destinations

src/wallet/test/util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
2424
LOCK2(wallet->cs_wallet, ::cs_main);
2525
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
2626
}
27-
wallet->LoadWallet();
2827
{
2928
LOCK(wallet->cs_wallet);
3029
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

0 commit comments

Comments
 (0)