forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wallet: wtx cached balances test coverage + getAvailableCredit problem fix. #1810
Merged
furszy
merged 7 commits into
PIVX-Project:master
from
furszy:2020_cached_balances_unit_test
Sep 1, 2020
Merged
Wallet: wtx cached balances test coverage + getAvailableCredit problem fix. #1810
furszy
merged 7 commits into
PIVX-Project:master
from
furszy:2020_cached_balances_unit_test
Sep 1, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Essentially adding unit test coverage for the CWalletTx cached balances structure and fake block creation flow to expand the unit test coverage of the wallet in the future. Plus, popping up an issue in `CWalletTx::GetAvailableCredit`. Issue description: As is now, `CWalletTx::GetAvailableCredit` is using the AmountType::CREDIT cached storage when should be using AmountType::AVAILABLE_CREDIT. So, as them are different type of balances and are using the same storage position, only one of those is stored and the other one returns, invalidly, the value of the first one cached.
3973167
to
d7813f8
Compare
Fuzzbawls
reviewed
Aug 25, 2020
…en it should be stored in AVAILABLE_CREDIT position.
…the GetCredit/GetCacheableAmount methods (it was wrong there, causing issues between different balances amount types) and moved GetColdStakingCredit and GetStakeDelegationCredit to the proper GetAvailableCredit where them will be, correctly, cached in AVAILABLE_CREDIT position.
d7813f8
to
ba2a5b0
Compare
random-zebra
approved these changes
Aug 30, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK cecb071
Fuzzbawls
approved these changes
Sep 1, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK cecb071
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added test coverage for the
CWalletTx
balances cache structure to verify the correctness ofCREDIT/ISMINE_SPENDABLE
,DEBIT/ISMINE_SPENDABLE
,AVAILABLE_CREDIT/ISMINE_SPENDABLE
, and a 'fake' block creation flow to verifyCWallet::GetUnconfirmedBalance
. (Leaving for a future PR, the cold staking balance types coverage)Plus, popped up an issue in
CWalletTx::GetAvailableCredit
that is solved too.Issue description:
As is now,
CWalletTx::GetAvailableCredit
is caching the amount using the AmountType::CREDIT when need to be using AmountType::AVAILABLE_CREDIT.As them are different type of balances and are using the same cache position, only one of those is stored and the other one returns, invalidly, the value of the first one cached.
I intentionally have committed the unit test before the fix. So it can be tested easier with and without the fix. Placing the repo's head at 7f45afd, the
wallet_tests.cpp
will fail due this issue. Then can move to the next one (or directly to the last one) and it will successfully pass.