mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-12 06:53:11 +02:00
wallet, bench: Use TestingSetup in CoinSelection benchmark
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user