Bitcoin Core  22.99.0
P2P Digital Currency
Macros | Typedefs | Functions | Variables
coinselector_tests.cpp File Reference
#include <consensus/amount.h>
#include <node/context.h>
#include <primitives/transaction.h>
#include <random.h>
#include <test/util/setup_common.h>
#include <util/translation.h>
#include <wallet/coincontrol.h>
#include <wallet/coinselection.h>
#include <wallet/spend.h>
#include <wallet/test/wallet_test_fixture.h>
#include <wallet/wallet.h>
#include <boost/test/unit_test.hpp>
#include <random>
Include dependency graph for coinselector_tests.cpp:

Go to the source code of this file.

Macros

#define RUN_TESTS   100
 
#define RANDOM_REPEATS   5
 

Typedefs

typedef std::set< CInputCoinCoinSet
 

Functions

static void add_coin (const CAmount &nValue, int nInput, std::vector< CInputCoin > &set)
 
static void add_coin (const CAmount &nValue, int nInput, CoinSet &set, CAmount fee=0, CAmount long_term_fee=0)
 
static void add_coin (std::vector< COutput > &coins, CWallet &wallet, const CAmount &nValue, int nAge=6 *24, bool fIsFromMe=false, int nInput=0, bool spendable=false)
 
static bool equal_sets (CoinSet a, CoinSet b)
 
static CAmount make_hard_case (int utxos, std::vector< CInputCoin > &utxo_pool)
 
std::vector< OutputGroup > & GroupCoins (const std::vector< CInputCoin > &coins)
 
std::vector< OutputGroup > & GroupCoins (const std::vector< COutput > &coins)
 
std::vector< OutputGroup > & KnapsackGroupOutputs (const std::vector< COutput > &coins, CWallet &wallet, const CoinEligibilityFilter &filter)
 
 BOOST_AUTO_TEST_CASE (bnb_search_test)
 
 BOOST_AUTO_TEST_CASE (knapsack_solver_test)
 
 BOOST_AUTO_TEST_CASE (ApproximateBestSubset)
 
 BOOST_AUTO_TEST_CASE (SelectCoins_test)
 
 BOOST_AUTO_TEST_CASE (waste_test)
 

Variables

static const CoinEligibilityFilter filter_standard (1, 6, 0)
 
static const CoinEligibilityFilter filter_confirmed (1, 1, 0)
 
static const CoinEligibilityFilter filter_standard_extra (6, 6, 0)
 

Macro Definition Documentation

◆ RANDOM_REPEATS

#define RANDOM_REPEATS   5

Definition at line 27 of file coinselector_tests.cpp.

◆ RUN_TESTS

#define RUN_TESTS   100

Definition at line 23 of file coinselector_tests.cpp.

Typedef Documentation

◆ CoinSet

typedef std::set<CInputCoin> CoinSet

Definition at line 29 of file coinselector_tests.cpp.

Function Documentation

◆ add_coin() [1/3]

static void add_coin ( const CAmount nValue,
int  nInput,
CoinSet set,
CAmount  fee = 0,
CAmount  long_term_fee = 0 
)
static

Definition at line 43 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ add_coin() [2/3]

static void add_coin ( const CAmount nValue,
int  nInput,
std::vector< CInputCoin > &  set 
)
static

Definition at line 35 of file coinselector_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_coin() [3/3]

static void add_coin ( std::vector< COutput > &  coins,
CWallet wallet,
const CAmount nValue,
int  nAge = 6*24,
bool  fIsFromMe = false,
int  nInput = 0,
bool  spendable = false 
)
static

Definition at line 55 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( ApproximateBestSubset  )

Definition at line 597 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( bnb_search_test  )

Definition at line 136 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( knapsack_solver_test  )

Definition at line 316 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( SelectCoins_test  )

Definition at line 620 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( waste_test  )

Definition at line 666 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ equal_sets()

static bool equal_sets ( CoinSet  a,
CoinSet  b 
)
static

Definition at line 84 of file coinselector_tests.cpp.

Here is the caller graph for this function:

◆ GroupCoins() [1/2]

std::vector<OutputGroup>& GroupCoins ( const std::vector< CInputCoin > &  coins)
inline

Definition at line 102 of file coinselector_tests.cpp.

Here is the caller graph for this function:

◆ GroupCoins() [2/2]

std::vector<OutputGroup>& GroupCoins ( const std::vector< COutput > &  coins)
inline

Definition at line 113 of file coinselector_tests.cpp.

◆ KnapsackGroupOutputs()

std::vector<OutputGroup>& KnapsackGroupOutputs ( const std::vector< COutput > &  coins,
CWallet wallet,
const CoinEligibilityFilter filter 
)
inline

Definition at line 124 of file coinselector_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_hard_case()

static CAmount make_hard_case ( int  utxos,
std::vector< CInputCoin > &  utxo_pool 
)
static

Definition at line 90 of file coinselector_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ filter_confirmed

const CoinEligibilityFilter filter_confirmed(1, 1, 0)
static

◆ filter_standard

const CoinEligibilityFilter filter_standard(1, 6, 0)
static

◆ filter_standard_extra

const CoinEligibilityFilter filter_standard_extra(6, 6, 0)
static