Skip to content

Commit e3687f7

Browse files
committed
test, bench: remove globals vCoins and testWallet from test and bench
adapted from a5595b1 and 5e54aa9 in bitcoin#23288. changes to coinselector_tests must be reverted before backports related to it are done as these changes are primarily motivated by bitcoin#21866 taking away the global chainstate, which breaks coinselector_tests and these changes skips over a lot of backporting, making them incompatible with backporting efforts (or even the commits its adapted from). the existing behaviour was that it creates its own testNode but doesn't populate it with a ChainstateManager (or much at all) while the rest of the client uses WalletTestingSetup's values. for the longest time this was fine because addCoins > listMNCollaterials > ChainActive() meant that it was using the fallback, but when chainstate globals are removed, WalletTestingSetup's values can't serve as a fallback anymore as it'd now be looking for NodeContext::chainman::m_chain, and chainman wasn't setup with testNode and the tests crash.
1 parent 0f4184c commit e3687f7

File tree

2 files changed

+209
-207
lines changed

2 files changed

+209
-207
lines changed

src/bench/coin_selection.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,16 @@ static void CoinSelection(benchmark::Bench& bench)
6161
}
6262

6363
typedef std::set<CInputCoin> CoinSet;
64-
static NodeContext testNode;
65-
static auto testChain = interfaces::MakeChain(testNode);
66-
static CWallet testWallet(testChain.get(), /*coinjoin_loader=*/ nullptr, "", CreateDummyWalletDatabase());
67-
std::vector<std::unique_ptr<CWalletTx>> wtxn;
6864

6965
// Copied from src/wallet/test/coinselector_tests.cpp
7066
static void add_coin(const CAmount& nValue, int nInput, std::vector<OutputGroup>& set)
7167
{
7268
CMutableTransaction tx;
7369
tx.vout.resize(nInput + 1);
7470
tx.vout[nInput].nValue = nValue;
75-
std::unique_ptr<CWalletTx> wtx = std::make_unique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
71+
CInputCoin coin(MakeTransactionRef(tx), nInput);
7672
set.emplace_back();
77-
set.back().Insert(COutput(wtx.get(), nInput, 0, true, true, true).GetInputCoin(), 0, true, 0, 0, false);
78-
wtxn.emplace_back(std::move(wtx));
73+
set.back().Insert(coin, 0, true, 0, 0, false);
7974
}
8075
// Copied from src/wallet/test/coinselector_tests.cpp
8176
static CAmount make_hard_case(int utxos, std::vector<OutputGroup>& utxo_pool)
@@ -93,7 +88,6 @@ static CAmount make_hard_case(int utxos, std::vector<OutputGroup>& utxo_pool)
9388
static void BnBExhaustion(benchmark::Bench& bench)
9489
{
9590
// Setup
96-
testWallet.SetupLegacyScriptPubKeyMan();
9791
std::vector<OutputGroup> utxo_pool;
9892
CoinSet selection;
9993
CAmount value_ret = 0;

0 commit comments

Comments
 (0)