Wallet: wtx cached balances test coverage + getAvailableCredit problem fix.#1810
Merged
furszy merged 7 commits intoSep 1, 2020
Merged
Conversation
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
Fuzzbawls
approved these changes
Sep 1, 2020
This file contains hidden or 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
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
CWalletTxbalances 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::GetAvailableCreditthat is solved too.Issue description:
As is now,
CWalletTx::GetAvailableCreditis 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.cppwill fail due this issue. Then can move to the next one (or directly to the last one) and it will successfully pass.