wallet, bench: Use TestingSetup in CoinSelection benchmark

This commit is contained in:
Ava Chow
2026-01-19 12:32:43 -08:00
parent e7d67c9fd9
commit b69f989dc5

View File

@@ -12,8 +12,10 @@
#include <primitives/transaction.h>
#include <random.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <util/result.h>
#include <wallet/coinselection.h>
#include <wallet/context.h>
#include <wallet/spend.h>
#include <wallet/test/util.h>
#include <wallet/transaction.h>
@@ -26,19 +28,7 @@
#include <utility>
#include <vector>
using node::NodeContext;
using wallet::AttemptSelection;
using wallet::CHANGE_LOWER;
using wallet::COutput;
using wallet::CWallet;
using wallet::CWalletTx;
using wallet::CoinEligibilityFilter;
using wallet::CoinSelectionParams;
using wallet::CreateMockableWalletDatabase;
using wallet::OutputGroup;
using wallet::SelectCoinsBnB;
using wallet::TxStateInactive;
namespace wallet {
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
{
static int nextLockTime = 0;
@@ -58,9 +48,8 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
static void CoinSelection(benchmark::Bench& bench)
{
NodeContext node;
auto chain = interfaces::MakeChain(node);
CWallet wallet(chain.get(), "", CreateMockableWalletDatabase());
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
CWallet wallet(test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase());
std::vector<std::unique_ptr<CWalletTx>> wtxs;
LOCK(wallet.cs_wallet);
@@ -139,3 +128,4 @@ static void BnBExhaustion(benchmark::Bench& bench)
BENCHMARK(CoinSelection);
BENCHMARK(BnBExhaustion);
}; // namespace wallet