From da37e91b394da0d8352e50c0de4da067def6e81f Mon Sep 17 00:00:00 2001 From: qwahzi Date: Thu, 17 Nov 2022 04:14:55 -0600 Subject: [PATCH] Update qt.cpp to match block_count RPC & fix bug with pruned display (#4000) * Update qt.cpp to match block_count RPC & fix bug with pruned display Currently the QT wallet 1) does not show cemented count, 2) has "Full" directly appended to the unchecked count (no comma or space), and the "Pruned" count is always empty (due to a minor concatenation bug). This change fixes that * Update qt.cpp Removing if-statements for cemented and unchecked, per https://github.com/nanocurrency/nano-node/pull/4000#pullrequestreview-1182747759 * Update qt.cpp Renaming "Queued" to "Unchecked" per colloquial usage and comment here: https://github.com/nanocurrency/nano-node/pull/4000#issuecomment-1317202823 * Fix unit test wallet.enter_password Search that the status line starts with the right words and ignore the counts, which are not directly relevant to this test. Co-authored-by: Dimitrios Siganos --- nano/qt/qt.cpp | 10 ++++------ nano/qt_test/qt.cpp | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/nano/qt/qt.cpp b/nano/qt/qt.cpp index 8a43f614..6675bb6f 100644 --- a/nano/qt/qt.cpp +++ b/nano/qt/qt.cpp @@ -957,15 +957,13 @@ std::string nano_qt::status::text () } result += ", Blocks: "; - if (unchecked != 0 && wallet.node.bootstrap_initiator.in_progress ()) - { - count_string += ", Queued: " + std::to_string (unchecked); - } + count_string += ", Unchecked: " + std::to_string (unchecked); + count_string += ", Cemented: " + std::to_string (cemented); if (wallet.node.flags.enable_pruning) { - count_string += "Full: " + std::to_string (wallet.wallet_m->wallets.node.ledger.cache.block_count - wallet.wallet_m->wallets.node.ledger.cache.pruned_count); - count_string += ", Pruned: ", std::to_string (wallet.wallet_m->wallets.node.ledger.cache.pruned_count); + count_string += ", Full: " + std::to_string (wallet.wallet_m->wallets.node.ledger.cache.block_count - wallet.wallet_m->wallets.node.ledger.cache.pruned_count); + count_string += ", Pruned: " + std::to_string (wallet.wallet_m->wallets.node.ledger.cache.pruned_count); } result += count_string.c_str (); diff --git a/nano/qt_test/qt.cpp b/nano/qt_test/qt.cpp index 076bb492..9cebdcf9 100644 --- a/nano/qt_test/qt.cpp +++ b/nano/qt_test/qt.cpp @@ -272,7 +272,7 @@ TEST (wallet, enter_password) QTest::mouseClick (wallet->settings.lock_toggle, Qt::LeftButton); QTest::mouseClick (wallet->settings.lock_toggle, Qt::LeftButton); test_application->processEvents (); - ASSERT_EQ ("Status: Wallet password empty, Blocks: 1", wallet->status->text ().toStdString ()); + ASSERT_NE (wallet->status->text ().toStdString ().rfind ("Status: Wallet password empty", 0), std::string::npos); { auto transaction (system.nodes[0]->wallets.tx_begin_write ()); ASSERT_FALSE (system.wallet (0)->store.rekey (transaction, "abc")); @@ -280,12 +280,12 @@ TEST (wallet, enter_password) QTest::mouseClick (wallet->settings_button, Qt::LeftButton); QTest::mouseClick (wallet->settings.lock_toggle, Qt::LeftButton); test_application->processEvents (); - ASSERT_EQ ("Status: Wallet locked, Blocks: 1", wallet->status->text ().toStdString ()); + ASSERT_NE (wallet->status->text ().toStdString ().rfind ("Status: Wallet locked", 0), std::string::npos); wallet->settings.new_password->setText (""); QTest::keyClicks (wallet->settings.password, "abc"); QTest::mouseClick (wallet->settings.lock_toggle, Qt::LeftButton); test_application->processEvents (); - ASSERT_EQ ("Status: Running, Blocks: 1", wallet->status->text ().toStdString ()); + ASSERT_NE (wallet->status->text ().toStdString ().rfind ("Status: Running", 0), std::string::npos); ASSERT_EQ ("", wallet->settings.password->text ()); }