[wallet] Add regression test for vValue sort order #7293

Merged
merged 2 commits into from Jan 7, 2016

Conversation

Projects
None yet
4 participants
@MarcoFalke
Member

MarcoFalke commented Jan 4, 2016

vValue is sorted from high to low. This adds a regression test such that pulls like #7183 would fail travis.

@MarcoFalke

This comment has been minimized.

Show comment
Hide comment
@MarcoFalke

MarcoFalke Jan 4, 2016

Member

Note: #7183 was changed in the meantime, the original diff might come in handy to test this pull:

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d23d54e..3d1f58c 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1605,7 +1605,7 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
         bool fReachedTarget = false;
         for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
         {
-            for (unsigned int i = 0; i < vValue.size(); i++)
+            for (unsigned int i = 0; i < vValue.size() && !fReachedTarget; i++)
             {
                 //The solver here uses a randomized algorithm,
                 //the randomness serves no real security purpose but is just
@@ -1625,8 +1625,6 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
                             nBest = nTotal;
                             vfBest = vfIncluded;
                         }
-                        nTotal -= vValue[i].first;
-                        vfIncluded[i] = false;
                     }
                 }
             }
Member

MarcoFalke commented Jan 4, 2016

Note: #7183 was changed in the meantime, the original diff might come in handy to test this pull:

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d23d54e..3d1f58c 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1605,7 +1605,7 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
         bool fReachedTarget = false;
         for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
         {
-            for (unsigned int i = 0; i < vValue.size(); i++)
+            for (unsigned int i = 0; i < vValue.size() && !fReachedTarget; i++)
             {
                 //The solver here uses a randomized algorithm,
                 //the randomness serves no real security purpose but is just
@@ -1625,8 +1625,6 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
                             nBest = nTotal;
                             vfBest = vfIncluded;
                         }
-                        nTotal -= vValue[i].first;
-                        vfIncluded[i] = false;
                     }
                 }
             }
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jan 5, 2016

Member

utACK

Member

laanwj commented Jan 5, 2016

utACK

@Xekyo

This comment has been minimized.

Show comment
Hide comment
@Xekyo

Xekyo Jan 5, 2016

Contributor

ACK: Fails for the referenced original PR #7183.

Contributor

Xekyo commented Jan 5, 2016

ACK: Fails for the referenced original PR #7183.

@laanwj laanwj merged commit faf538b into bitcoin:master Jan 7, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Jan 7, 2016

Merge pull request #7293
faf538b [trivial] Merge test cases and replace CENT with COIN (MarcoFalke)
fa3c7e6 [wallet] Add regression test for vValue sort order (MarcoFalke)

laanwj added a commit that referenced this pull request Jan 7, 2016

[wallet] Add regression test for vValue sort order
- [wallet] Add regression test for vValue sort order
- [trivial] Merge test cases and replace CENT with COIN

Github-Pull: #7293
Rebased-From: fa3c7e6 faf538b
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jan 7, 2016

Member

Cherry-picked to 0.12 as ff9b610

Member

laanwj commented Jan 7, 2016

Cherry-picked to 0.12 as ff9b610

@MarcoFalke MarcoFalke deleted the MarcoFalke:Mf1601-wallet-vValue branch Jan 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment