File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -428,4 +428,29 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
428
428
}
429
429
}
430
430
431
+ // Check that GetImmatureCredit() returns a newly calculated value instead of
432
+ // the cached value after a MarkDirty() call.
433
+ //
434
+ // This is a regression test written to verify a bugfix for the immature credit
435
+ // function. Similar tests probably should be written for the other credit and
436
+ // debit functions.
437
+ BOOST_FIXTURE_TEST_CASE (coin_mark_dirty_immature_credit, TestChain100Setup)
438
+ {
439
+ CWallet wallet;
440
+ CWalletTx wtx (&wallet, MakeTransactionRef (coinbaseTxns.back ()));
441
+ LOCK2 (cs_main, wallet.cs_wallet );
442
+ wtx.hashBlock = chainActive.Tip ()->GetBlockHash ();
443
+ wtx.nIndex = 0 ;
444
+
445
+ // Call GetImmatureCredit() once before adding the key to the wallet to
446
+ // cache the current immature credit amount, which is 0.
447
+ BOOST_CHECK_EQUAL (wtx.GetImmatureCredit (), 0 );
448
+
449
+ // Invalidate the cached value, add the key, and make sure a new immature
450
+ // credit amount is calculated.
451
+ wtx.MarkDirty ();
452
+ wallet.AddKeyPubKey (coinbaseKey, coinbaseKey.GetPubKey ());
453
+ BOOST_CHECK_EQUAL (wtx.GetImmatureCredit (), 50 *COIN);
454
+ }
455
+
431
456
BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments