aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2018-11-13 04:57:10 +0000
committerBen Woosley <ben.woosley@gmail.com>2018-11-13 12:51:16 -0500
commitbd3b0361d840bff95988a048abf70ade94d80524 (patch)
tree4c542682c6aac615aa2cc1760fef4faba7195d52 /src/wallet/test
parent3002d6cf31821622e9f21d51e536cafc5cfb10ae (diff)
Add stop_block out arg to ScanForWalletTransactions
Accurately reports the last block successfully scanned, replacing a return of the chain tip, which represented possibly inaccurated data in a race condition.
Diffstat (limited to 'src/wallet/test')
-rw-r--r--src/wallet/test/wallet_tests.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index dccda1acf1..46d9b5b238 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -53,9 +53,10 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
AddKey(wallet, coinbaseKey);
WalletRescanReserver reserver(&wallet);
reserver.reserve();
- const CBlockIndex* stop_block;
- BOOST_CHECK_EQUAL(wallet.ScanForWalletTransactions(oldTip, nullptr, reserver, stop_block), CWallet::ScanResult::SUCCESS);
- BOOST_CHECK_EQUAL(stop_block, null_block);
+ const CBlockIndex *stop_block, *failed_block;
+ BOOST_CHECK_EQUAL(wallet.ScanForWalletTransactions(oldTip, nullptr, reserver, failed_block, stop_block), CWallet::ScanResult::SUCCESS);
+ BOOST_CHECK_EQUAL(failed_block, null_block);
+ BOOST_CHECK_EQUAL(stop_block, newTip);
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN);
}
@@ -70,9 +71,10 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
AddKey(wallet, coinbaseKey);
WalletRescanReserver reserver(&wallet);
reserver.reserve();
- const CBlockIndex* stop_block;
- BOOST_CHECK_EQUAL(wallet.ScanForWalletTransactions(oldTip, nullptr, reserver, stop_block), CWallet::ScanResult::FAILURE);
- BOOST_CHECK_EQUAL(oldTip, stop_block);
+ const CBlockIndex *stop_block, *failed_block;
+ BOOST_CHECK_EQUAL(wallet.ScanForWalletTransactions(oldTip, nullptr, reserver, failed_block, stop_block), CWallet::ScanResult::FAILURE);
+ BOOST_CHECK_EQUAL(failed_block, oldTip);
+ BOOST_CHECK_EQUAL(stop_block, newTip);
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN);
}
@@ -291,9 +293,10 @@ public:
WalletRescanReserver reserver(wallet.get());
reserver.reserve();
const CBlockIndex* const null_block = nullptr;
- const CBlockIndex* stop_block;
- BOOST_CHECK_EQUAL(wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, stop_block), CWallet::ScanResult::SUCCESS);
- BOOST_CHECK_EQUAL(stop_block, null_block);
+ const CBlockIndex *stop_block, *failed_block;
+ BOOST_CHECK_EQUAL(wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, failed_block, stop_block), CWallet::ScanResult::SUCCESS);
+ BOOST_CHECK_EQUAL(stop_block, chainActive.Tip());
+ BOOST_CHECK_EQUAL(failed_block, null_block);
}
~ListCoinsTestingSetup()