The param min_viable_change is never used in any of the subsequent tests and can be removed.
test: Remove unused coin_selection param #26110
pull yancyribbens wants to merge 1 commits into bitcoin:master from yancyribbens:remove-unused-bnb-test-param changing 1 files +0 −1-
yancyribbens commented at 2:05 PM on September 16, 2022: contributor
- fanquake added the label Tests on Sep 16, 2022
-
achow101 commented at 2:58 PM on September 16, 2022: member
I don't think it is unused. There are a number of calls to
SelectCoinsin the following tests and that function usesmin_viable_change.Note that the tests are not exhaustive. If tests do not fail due to removal of code, it is not necessarily that the code was unnecessary or unused, but often that the test was deficient.
-
yancyribbens commented at 3:14 PM on September 16, 2022: contributor
@achow101 yes that's true, however this is part of
bnb_search_testwhich is testingSelectCoinsBnB.It's confusing that the tests use
SelectCoinsto callSelectCoinsBnBright now. -
DrahtBot commented at 3:50 AM on September 17, 2022: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers Concept NACK S3RK If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #26111 (refactor: Simplify bnb coin_selection test params by yancyribbens)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
S3RK commented at 7:39 AM on September 19, 2022: contributor
NACK. I added
min_viable_changeand it's definitely used. You can check it withgit grep min_viable_changeP.S.
min_viable_changeis not related to BnB algorithm. it's a parameter for the transaction building. -
yancyribbens commented at 7:52 AM on September 19, 2022: contributor
The test suit should fail then if it is used, however the tests all pass. Under what circumstance would
min_viable_changeaffect theBnBalgorithm? Maybe there's a test or assertion that can be added ifmin_viable_changesetting is important to the selection process. -
aureleoules commented at 6:52 PM on November 3, 2022: member
It's confusing that the tests use SelectCoins to call SelectCoinsBnB right now.
The coins supplied to the selection algorithm are of round value and match exactly the target, which is the reason why BnB should be used in
SelectCoins.Since BnB does not create change outputs, wouldn't it make sense to remove
min_viable_changefrom the test?<details> <summary>Suggestion</summary>
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index 264c0aa59..4a5309a4f 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -345,6 +345,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) coin_selection_params_bnb.m_effective_feerate = CFeeRate(0); const auto result10 = SelectCoins(*wallet, available_coins, selected_input, 10 * CENT, coin_control, coin_selection_params_bnb); BOOST_CHECK(result10); + BOOST_CHECK_EQUAL(result10->GetAlgo(), SelectionAlgorithm::BNB); } { std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase()); @@ -368,6 +369,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) CCoinControl coin_control; const auto result11 = SelectCoins(*wallet, available_coins, /*pre_set_inputs=*/{}, 10 * CENT, coin_control, coin_selection_params_bnb); BOOST_CHECK(EquivalentResult(expected_result, *result11)); + BOOST_CHECK_EQUAL(result11->GetAlgo(), SelectionAlgorithm::BNB); available_coins.Clear(); // more coins should be selected when effective fee < long term fee @@ -383,6 +385,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) add_coin(1 * CENT, 2, expected_result); const auto result12 = SelectCoins(*wallet, available_coins, /*pre_set_inputs=*/{}, 10 * CENT, coin_control, coin_selection_params_bnb); BOOST_CHECK(EquivalentResult(expected_result, *result12)); + BOOST_CHECK_EQUAL(result12->GetAlgo(), SelectionAlgorithm::BNB); available_coins.Clear(); // pre selected coin should be selected even if disadvantageous @@ -404,6 +407,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) available_coins.coins[OutputType::BECH32].erase(++available_coins.coins[OutputType::BECH32].begin()); const auto result13 = SelectCoins(*wallet, available_coins, selected_input, 10 * CENT, coin_control, coin_selection_params_bnb); BOOST_CHECK(EquivalentResult(expected_result, *result13)); + BOOST_CHECK_EQUAL(result13->GetAlgo(), SelectionAlgorithm::BNB); } }</details>
-
yancyribbens commented at 7:41 PM on November 3, 2022: contributor
The coins supplied to the selection algorithm are of round value and match exactly the target, which is the reason why BnB should be used in SelectCoins
It seems to me it would be cleaner to just test
BnBdirectly instead of indirectly testing viaSelectCoins, however, that seems like a much larger refactor.Since BnB does not create change outputs, wouldn't it make sense to remove min_viable_change from the test?
I think we are driving at the same thing.
BnBdoes not usemin_viable_changenor does it accept it as an argument, which is why I removed it in this PR. I think we could certainly add the assertion you suggested, although that seems like a separate change IMO from this PR. -
S3RK commented at 8:30 AM on November 7, 2022: contributor
min_viable_changeis used byComputeAndSetWastewithinSelectCoins. It just so happen that the tests pass with the current default valuemin_viable_change=0. I think there are a few ways to improve the test:- #26466
- Switch to use
SelectCoinsBnBinstead ofSelectCoins - initialise
min_viable_changewith 0 explicitly
However, I'm not sure whether option 3 is a good option in light of #26466
-
yancyribbens commented at 12:06 PM on November 7, 2022: contributor
SelectCoinsBnBusescost_of_change, nontmin_viable_changeto callComputeAndSetWaste:https://github.com/bitcoin/bitcoin/blob/master/src/wallet/coinselection.cpp#L159
As I mentioned above, I do think it's better to have the tests
bnb_search_testtestSelectCoinsBnBinstead of testingSelectCoins(option 2). In the meantime, sinceSelectCoinsBnBdoesn't usemin_viable_changewe can remove that param. - DrahtBot added the label Needs rebase on Jan 4, 2023
- yancyribbens force-pushed on Jan 19, 2023
-
test: Remove unused coin_selection param c65f842f7e
- DrahtBot removed the label Needs rebase on Jan 19, 2023
-
achow101 commented at 3:53 PM on April 25, 2023: member
The feature request didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open issues.
Closing due to lack of interest. Pull requests with improvements are always welcome.
- achow101 closed this on Apr 25, 2023
- bitcoin locked this on Apr 24, 2024