Bitcoin Core  0.19.99
P2P Digital Currency
Macros | Typedefs | Functions | Variables
coinselector_tests.cpp File Reference
#include <node/context.h>
#include <wallet/wallet.h>
#include <wallet/coinselection.h>
#include <wallet/coincontrol.h>
#include <amount.h>
#include <primitives/transaction.h>
#include <random.h>
#include <test/util/setup_common.h>
#include <wallet/test/wallet_test_fixture.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 CWallet testWallet (testChain.get(), WalletLocation(), WalletDatabase::CreateDummy())
 
static void add_coin (const CAmount &nValue, int nInput, std::vector< CInputCoin > &set)
 
static void add_coin (const CAmount &nValue, int nInput, CoinSet &set)
 
static void add_coin (CWallet &wallet, const CAmount &nValue, int nAge=6 *24, bool fIsFromMe=false, int nInput=0, bool spendable=false)
 
static void add_coin (const CAmount &nValue, int nAge=6 *24, bool fIsFromMe=false, int nInput=0, bool spendable=false)
 
static void empty_wallet (void)
 
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)
 
 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)
 

Variables

std::vector< std::unique_ptr< CWalletTx > > wtxn
 
static std::vector< COutputvCoins
 
static NodeContext testNode
 
static auto testChain = interfaces::MakeChain(testNode)
 
static CAmount balance = 0
 
CoinEligibilityFilter filter_standard (1, 6, 0)
 
CoinEligibilityFilter filter_confirmed (1, 1, 0)
 
CoinEligibilityFilter filter_standard_extra (6, 6, 0)
 
CoinSelectionParams coin_selection_params (false, 0, 0, CFeeRate(0), 0)
 

Macro Definition Documentation

◆ RANDOM_REPEATS

#define RANDOM_REPEATS   5

Definition at line 25 of file coinselector_tests.cpp.

◆ RUN_TESTS

#define RUN_TESTS   100

Definition at line 21 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/4]

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

Definition at line 42 of file coinselector_tests.cpp.

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

◆ add_coin() [2/4]

static void add_coin ( const CAmount nValue,
int  nInput,
CoinSet set 
)
static

Definition at line 50 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ add_coin() [3/4]

static void add_coin ( CWallet wallet,
const CAmount nValue,
int  nAge = 6*24,
bool  fIsFromMe = false,
int  nInput = 0,
bool  spendable = false 
)
static

Definition at line 58 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ add_coin() [4/4]

static void add_coin ( const CAmount nValue,
int  nAge = 6*24,
bool  fIsFromMe = false,
int  nInput = 0,
bool  spendable = false 
)
static

Definition at line 88 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( bnb_search_test  )

Definition at line 135 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( knapsack_solver_test  )

Definition at line 297 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( ApproximateBestSubset  )

Definition at line 577 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( SelectCoins_test  )

Definition at line 601 of file coinselector_tests.cpp.

Here is the call graph for this function:

◆ empty_wallet()

static void empty_wallet ( void  )
static

Definition at line 93 of file coinselector_tests.cpp.

Here is the caller graph for this function:

◆ equal_sets()

static bool equal_sets ( CoinSet  a,
CoinSet  b 
)
static

Definition at line 100 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 118 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 126 of file coinselector_tests.cpp.

◆ make_hard_case()

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

Definition at line 106 of file coinselector_tests.cpp.

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

◆ testWallet()

static CWallet testWallet ( testChain.  get(),
WalletLocation()  ,
WalletDatabase::CreateDummy()   
)
static
Here is the caller graph for this function:

Variable Documentation

◆ balance

CAmount balance = 0
static

Definition at line 35 of file coinselector_tests.cpp.

◆ coin_selection_params

CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0)

◆ filter_confirmed

CoinEligibilityFilter filter_confirmed(1, 1, 0)

◆ filter_standard

CoinEligibilityFilter filter_standard(1, 6, 0)

◆ filter_standard_extra

CoinEligibilityFilter filter_standard_extra(6, 6, 0)

◆ testChain

auto testChain = interfaces::MakeChain(testNode)
static

Definition at line 33 of file coinselector_tests.cpp.

◆ testNode

NodeContext testNode
static

Definition at line 32 of file coinselector_tests.cpp.

◆ vCoins

std::vector<COutput> vCoins
static

Definition at line 31 of file coinselector_tests.cpp.

◆ wtxn

std::vector<std::unique_ptr<CWalletTx> > wtxn

Definition at line 27 of file coinselector_tests.cpp.