diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-10-22 16:26:18 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-10-22 17:49:43 -0400 |
commit | a78c2298080f173d0266e708267458a72eb2f600 (patch) | |
tree | fb952a5a8b6f159628b270da394030d27f57dcd9 | |
parent | 224e90d9fdf895d3ee212edcf7dec3eb4d94ce91 (diff) |
tests: Place into mapWallet in coinselector_tests
Instead of using AddToWallet so that making a COutput will work,
directly add the transaction into wallet.mapWallet. This bypasses many
checks that AddToWallet will do which are pointless and just slow down
this test.
-rw-r--r-- | src/wallet/test/coinselector_tests.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index e880e13845..8606924bb3 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -71,13 +71,18 @@ static void add_coin(std::vector<COutput>& coins, CWallet& wallet, const CAmount // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe() tx.vin.resize(1); } - CWalletTx* wtx = wallet.AddToWallet(MakeTransactionRef(std::move(tx)), /* confirm= */ {}); + uint256 txid = tx.GetHash(); + + LOCK(wallet.cs_wallet); + auto ret = wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(MakeTransactionRef(std::move(tx)))); + assert(ret.second); + CWalletTx& wtx = (*ret.first).second; if (fIsFromMe) { - wtx->m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, 1); - wtx->m_is_cache_empty = false; + wtx.m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, 1); + wtx.m_is_cache_empty = false; } - COutput output(wallet, *wtx, nInput, nAge, true /* spendable */, true /* solvable */, true /* safe */); + COutput output(wallet, wtx, nInput, nAge, true /* spendable */, true /* solvable */, true /* safe */); coins.push_back(output); } |