From 3002d6cf31821622e9f21d51e536cafc5cfb10ae Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Sun, 29 Apr 2018 15:45:44 +0000 Subject: Return a status enum from ScanForWalletTransactions Return the failed block as an out var. This clarifies the outcome as the prior return value could be null due to user abort or failure. --- src/qt/test/wallettests.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/qt') diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index f02fd8aea7..5646070a3f 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -146,7 +146,12 @@ void TestGUI() auto locked_chain = wallet->chain().lock(); WalletRescanReserver reserver(wallet.get()); reserver.reserve(); - wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, true); + const CBlockIndex* const null_block = nullptr; + const CBlockIndex* stop_block; + QCOMPARE( + wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, stop_block, true /* fUpdate */), + CWallet::ScanResult::SUCCESS); + QCOMPARE(stop_block, null_block); } wallet->SetBroadcastTransactions(true); -- cgit v1.2.3 From bd3b0361d840bff95988a048abf70ade94d80524 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Tue, 13 Nov 2018 04:57:10 +0000 Subject: 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. --- src/qt/test/wallettests.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/qt') diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 5646070a3f..610d83acb6 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -147,11 +147,12 @@ void TestGUI() WalletRescanReserver reserver(wallet.get()); reserver.reserve(); const CBlockIndex* const null_block = nullptr; - const CBlockIndex* stop_block; + const CBlockIndex *stop_block, *failed_block; QCOMPARE( - wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, stop_block, true /* fUpdate */), + wallet->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, failed_block, stop_block, true /* fUpdate */), CWallet::ScanResult::SUCCESS); - QCOMPARE(stop_block, null_block); + QCOMPARE(stop_block, chainActive.Tip()); + QCOMPARE(failed_block, null_block); } wallet->SetBroadcastTransactions(true); -- cgit v1.2.3