diff options
| author | MarcoFalke <[email protected]> | 2017-03-02 22:30:12 +0100 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2017-03-02 22:30:15 +0100 |
| commit | f7ec7cfd38b543ba81ac7bed5b77f9a19739460b (patch) | |
| tree | 7df23cc931e88d221bb73436998566b7806ca32b /src | |
| parent | Merge #9143: Refactor ZapWalletTxes to avoid layer violations (diff) | |
| parent | Add test for CWalletTx::GetImmatureCredit() returning stale values. (diff) | |
| download | discoin-f7ec7cfd38b543ba81ac7bed5b77f9a19739460b.tar.xz discoin-f7ec7cfd38b543ba81ac7bed5b77f9a19739460b.zip | |
Merge #9359: Add test for CWalletTx::GetImmatureCredit() returning stale values.
7ed143c Add test for CWalletTx::GetImmatureCredit() returning stale values. (Russell Yanofsky)
Tree-SHA512: c95088ed6dfc5a0774ddaa2fe14ac0a9ebd830922a4d77100ec3d51fdeb6df40ad97de4f2ea970ed0f4122dcc0022ee1d43ab3c7188becd7f90c1c6af0ed39b7
Diffstat (limited to 'src')
| -rw-r--r-- | src/wallet/test/wallet_tests.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 7ac2112dd..fe212e562 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -428,4 +428,29 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) } } +// Check that GetImmatureCredit() returns a newly calculated value instead of +// the cached value after a MarkDirty() call. +// +// This is a regression test written to verify a bugfix for the immature credit +// function. Similar tests probably should be written for the other credit and +// debit functions. +BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) +{ + CWallet wallet; + CWalletTx wtx(&wallet, MakeTransactionRef(coinbaseTxns.back())); + LOCK2(cs_main, wallet.cs_wallet); + wtx.hashBlock = chainActive.Tip()->GetBlockHash(); + wtx.nIndex = 0; + + // Call GetImmatureCredit() once before adding the key to the wallet to + // cache the current immature credit amount, which is 0. + BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 0); + + // Invalidate the cached value, add the key, and make sure a new immature + // credit amount is calculated. + wtx.MarkDirty(); + wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); + BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 50*COIN); +} + BOOST_AUTO_TEST_SUITE_END() |