@@ -840,7 +840,7 @@ BOOST_AUTO_TEST_CASE(waste_test)
840
840
// Waste without change is the excess and difference between fee and long term fee
841
841
add_coin (1 * COIN, 1 , selection, fee, fee - fee_diff);
842
842
add_coin (2 * COIN, 2 , selection, fee, fee - fee_diff);
843
- const CAmount waste_nochange1 = GetSelectionWaste (selection, 0 , target);
843
+ const CAmount waste_nochange1 = GetSelectionWaste (selection, /* change_cost= */ std::nullopt , target);
844
844
BOOST_CHECK_EQUAL (fee_diff * 2 + excess, waste_nochange1);
845
845
selection.clear ();
846
846
@@ -853,7 +853,7 @@ BOOST_AUTO_TEST_CASE(waste_test)
853
853
// Waste without change and fee == long term fee is just the excess
854
854
add_coin (1 * COIN, 1 , selection, fee, fee);
855
855
add_coin (2 * COIN, 2 , selection, fee, fee);
856
- BOOST_CHECK_EQUAL (excess, GetSelectionWaste (selection, 0 , target));
856
+ BOOST_CHECK_EQUAL (excess, GetSelectionWaste (selection, /* change_cost= */ std::nullopt , target));
857
857
selection.clear ();
858
858
859
859
// Waste will be greater when fee is greater, but long term fee is the same
@@ -876,7 +876,7 @@ BOOST_AUTO_TEST_CASE(waste_test)
876
876
// With long term fee greater than fee, waste should be less than when long term fee is less than fee
877
877
add_coin (1 * COIN, 1 , selection, fee, fee + fee_diff);
878
878
add_coin (2 * COIN, 2 , selection, fee, fee + fee_diff);
879
- const CAmount waste_nochange2 = GetSelectionWaste (selection, 0 , target);
879
+ const CAmount waste_nochange2 = GetSelectionWaste (selection, /* change_cost= */ std::nullopt , target);
880
880
BOOST_CHECK_EQUAL (fee_diff * -2 + excess, waste_nochange2);
881
881
BOOST_CHECK_LT (waste_nochange2, waste_nochange1);
882
882
selection.clear ();
@@ -885,7 +885,7 @@ BOOST_AUTO_TEST_CASE(waste_test)
885
885
add_coin (1 * COIN, 1 , selection, fee, fee);
886
886
add_coin (2 * COIN, 2 , selection, fee, fee);
887
887
const CAmount exact_target{in_amt - fee * 2 };
888
- BOOST_CHECK_EQUAL (0 , GetSelectionWaste (selection, /* change_cost=*/ 0 , exact_target));
888
+ BOOST_CHECK_EQUAL (0 , GetSelectionWaste (selection, /* change_cost=*/ std::nullopt , exact_target));
889
889
selection.clear ();
890
890
891
891
// No Waste when (fee - long_term_fee) == (-cost_of_change), and no excess
@@ -899,15 +899,15 @@ BOOST_AUTO_TEST_CASE(waste_test)
899
899
const CAmount new_target{in_amt - fee * 2 - fee_diff * 2 };
900
900
add_coin (1 * COIN, 1 , selection, fee, fee + fee_diff);
901
901
add_coin (2 * COIN, 2 , selection, fee, fee + fee_diff);
902
- BOOST_CHECK_EQUAL (0 , GetSelectionWaste (selection, /* change_cost=*/ 0 , new_target));
902
+ BOOST_CHECK_EQUAL (0 , GetSelectionWaste (selection, /* change_cost=*/ std::nullopt , new_target));
903
903
selection.clear ();
904
904
905
905
// Negative waste when the long term fee is greater than the current fee and the selected value == target
906
906
const CAmount exact_target1{3 * COIN - 2 * fee};
907
907
const CAmount target_waste1{-2 * fee_diff}; // = (2 * fee) - (2 * (fee + fee_diff))
908
908
add_coin (1 * COIN, 1 , selection, fee, fee + fee_diff);
909
909
add_coin (2 * COIN, 2 , selection, fee, fee + fee_diff);
910
- BOOST_CHECK_EQUAL (target_waste1, GetSelectionWaste (selection, /* change_cost=*/ 0 , exact_target1));
910
+ BOOST_CHECK_EQUAL (target_waste1, GetSelectionWaste (selection, /* change_cost=*/ std::nullopt , exact_target1));
911
911
selection.clear ();
912
912
913
913
// Negative waste when the long term fee is greater than the current fee and change_cost < - (inputs * (fee - long_term_fee))
@@ -1071,7 +1071,7 @@ BOOST_AUTO_TEST_CASE(check_max_weight)
1071
1071
rand,
1072
1072
/* change_output_size=*/ 34 ,
1073
1073
/* min_change_target=*/ CENT,
1074
- /* effective_feerate=*/ CFeeRate (0 ),
1074
+ /* effective_feerate=*/ CFeeRate (1 ), // tiny feerate so the waste score isn't always 0.
1075
1075
/* long_term_feerate=*/ CFeeRate (0 ),
1076
1076
/* tx_noinputs_size=*/ 10 + 34 , // static header size + output size
1077
1077
/* avoid_partial=*/ false ,
@@ -1089,10 +1089,10 @@ BOOST_AUTO_TEST_CASE(check_max_weight)
1089
1089
target, cs_params, cc, [&](CWallet& wallet) {
1090
1090
CoinsResult available_coins;
1091
1091
for (int j = 0 ; j < 1515 ; ++j) {
1092
- add_coin (available_coins, wallet, CAmount (0.033 * COIN), CFeeRate ( 0 ) , 144 , false , 0 , true );
1092
+ add_coin (available_coins, wallet, CAmount (0.033 * COIN), cs_params. m_effective_feerate , 144 , false , 0 , true );
1093
1093
}
1094
1094
1095
- add_coin (available_coins, wallet, CAmount (50 * COIN), CFeeRate ( 0 ) , 144 , false , 0 , true );
1095
+ add_coin (available_coins, wallet, CAmount (50 * COIN), cs_params. m_effective_feerate , 144 , false , 0 , true );
1096
1096
return available_coins;
1097
1097
},
1098
1098
m_node);
@@ -1101,7 +1101,7 @@ BOOST_AUTO_TEST_CASE(check_max_weight)
1101
1101
// Verify that only the 50 BTC UTXO was selected
1102
1102
const auto & selection_res = result->GetInputSet ();
1103
1103
BOOST_CHECK (selection_res.size () == 1 );
1104
- BOOST_CHECK ((*selection_res.begin ())->GetEffectiveValue () == 50 * COIN);
1104
+ BOOST_CHECK ((*selection_res.begin ())->txout . nValue == 50 * COIN);
1105
1105
}
1106
1106
1107
1107
{
0 commit comments