12 #include <boost/test/unit_test.hpp> 15 BOOST_FIXTURE_TEST_SUITE(group_outputs_tests,
TestingSetup)
25 wallet->SetupDescriptorScriptPubKeyMans();
40 tx.
vout[0].nValue = nValue;
48 const auto& txout = wtx.
tx->vout.at(0);
80 std::shared_ptr<CWallet>
wallet{
nullptr};
86 bool avoid_partial_spends,
91 std::vector<OutputGroup>& groups_out = positive_only ? groups.
groups_by_type[type].positive_group :
98 int expected_with_partial_spends_size,
99 int expected_without_partial_spends_size,
103 GroupVerify(type, filter,
false, positive_only, expected_with_partial_spends_size);
105 GroupVerify(type, filter,
true, positive_only, expected_without_partial_spends_size);
123 unsigned long GROUP_SIZE = 10;
125 for (
unsigned long i = 0; i < GROUP_SIZE; i++) {
141 for (
unsigned long i = 0; i < GROUP_SIZE; i++) {
212 uint16_t NUM_SINGLE_ENTRIES = 101;
213 for (
unsigned long i = 0; i < NUM_SINGLE_ENTRIES; i++) {
218 int PREVIOUS_ROUND_COUNT = GROUP_SIZE * 2 + 1;
221 PREVIOUS_ROUND_COUNT + NUM_SINGLE_ENTRIES,
228 avoid_partial_groups_filter,
229 PREVIOUS_ROUND_COUNT + NUM_SINGLE_ENTRIES,
std::unique_ptr< interfaces::Chain > chain
std::map< OutputType, Groups > groups_by_type
Stores several 'Groups' whose were mapped by output type.
static void addCoin(CoinsResult &coins, CWallet &wallet, const CTxDestination &dest, const CAmount &nValue, bool is_from_me, CFeeRate fee_rate=CFeeRate(0), int depth=6)
static std::unique_ptr< CWallet > NewWallet(const node::NodeContext &m_node, const std::string &wallet_name="")
State of transaction not confirmed or conflicting with a known block and not in the mempool...
int64_t GetTxTime() const
std::shared_ptr< CWallet > wallet
std::map< OutputType, std::vector< COutput > > coins
int64_t CAmount
Amount in satoshis (Can be negative)
COutputs available for spending, stored by OutputType.
A transaction with a bunch of additional info that only the owner cares about.
CoinSelectionParams makeSelectionParams(FastRandomContext &rand, bool avoid_partial_spends)
void GroupVerify(const OutputType type, const CoinEligibilityFilter &filter, bool avoid_partial_spends, bool positive_only, int expected_size)
int CalculateMaximumSignedInputSize(const CTxOut &txout, const COutPoint outpoint, const SigningProvider *provider, bool can_grind_r, const CCoinControl *coin_control)
BOOST_AUTO_TEST_SUITE_END()
Indicate that this wallet supports DescriptorScriptPubKeyMan.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Txid GetHash() const
Compute the hash of this CMutableTransaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
Parameters for one iteration of Coin Selection.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Parameters for filtering which OutputGroups we may use in coin selection.
const Txid & GetHash() const LIFETIMEBOUND
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
#define BOOST_CHECK_EQUAL(v1, v2)
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
A mutable version of CTransaction.
static constexpr CAmount CENT
const uint256 & ToUint256() const LIFETIMEBOUND
std::shared_ptr< CWallet > wallet
void Add(OutputType type, const COutput &out)
std::optional< OutputType > OutputTypeFromDestination(const CTxDestination &dest)
Get the OutputType for a CTxDestination.
BOOST_AUTO_TEST_CASE(bnb_search_test)
FilteredOutputGroups GroupOutputs(const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters, std::vector< OutputGroup > &ret_discarded_groups)
Testing setup that configures a complete environment.
void GroupAndVerify(const OutputType type, const CoinEligibilityFilter &filter, int expected_with_partial_spends_size, int expected_without_partial_spends_size, bool positive_only)
#define Assert(val)
Identity function.
#define BOOST_CHECK(expr)
static constexpr CAmount COIN
The amount of satoshis in one BTC.