v29.4-roots.2 · Commit 15: [PATCH 15/21] fix(qt): clear stale peer details on refresh
src/qt/test/apptests.cpp
Before: src/qt/test/apptests.cpp · After: src/qt/test/apptests.cpp
File metadata
index 94aca70ed47e41bef1f27e90cad0289b440078bc..917ca09f48089a7e9a6093d5da68fd8e5f3e9317 100644
Download original patch · Release notes
Diff rows 1–82 of 82. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/qt/test/apptests.cpp
CHANGED
|
@@ -18,12 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
#include <QAction>
|
|
20
20
|
#include <QColor>
|
|
21
|
+
#include <QLabel>
|
|
21
22
|
#include <QLineEdit>
|
|
22
23
|
#include <QPixmap>
|
|
23
24
|
#include <QRegularExpression>
|
|
24
25
|
#include <QScopedPointer>
|
|
25
26
|
#include <QSignalSpy>
|
|
27
|
+
#include <QSortFilterProxyModel>
|
|
26
28
|
#include <QString>
|
|
29
|
+
#include <QTableView>
|
|
27
30
|
#include <QTest>
|
|
28
31
|
#include <QTextEdit>
|
|
29
32
|
#include <QtGlobal>
|
|
@@ -54,6 +57,60 @@ void TestRpcCommand(RPCConsole* console)
|
|
|
54
57
|
QCOMPARE(FindInConsole(output, pattern), QString("regtest"));
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
void TestPeerRefreshState(RPCConsole* console)
|
|
61
|
+
{
|
|
62
|
+
auto* peer_widget = console->findChild<QTableView*>("peerWidget");
|
|
63
|
+
QVERIFY(peer_widget);
|
|
64
|
+
auto* peer_proxy = qobject_cast<QSortFilterProxyModel*>(peer_widget->model());
|
|
65
|
+
QVERIFY(peer_proxy);
|
|
66
|
+
auto* peer_model = qobject_cast<PeerTableModel*>(peer_proxy->sourceModel());
|
|
67
|
+
QVERIFY(peer_model);
|
|
68
|
+
QCOMPARE(peer_model->rowCount(), 0);
|
|
69
|
+
|
|
70
|
+
QSignalSpy data_changed_spy(peer_model, &QAbstractItemModel::dataChanged);
|
|
71
|
+
QVERIFY(data_changed_spy.isValid());
|
|
72
|
+
peer_model->refresh();
|
|
73
|
+
QCOMPARE(data_changed_spy.count(), 0);
|
|
74
|
+
|
|
75
|
+
const auto set_label = [console](const char* name) {
|
|
76
|
+
QLabel* label = console->findChild<QLabel*>(name);
|
|
77
|
+
if (label) label->setText(QStringLiteral("stale"));
|
|
78
|
+
return label;
|
|
79
|
+
};
|
|
80
|
+
QLabel* time_offset = set_label("timeoffset");
|
|
81
|
+
QLabel* services = set_label("peerServices");
|
|
82
|
+
QLabel* sync_height = set_label("peerSyncHeight");
|
|
83
|
+
QLabel* common_height = set_label("peerCommonHeight");
|
|
84
|
+
QLabel* starting_height = set_label("peerHeight");
|
|
85
|
+
QLabel* ping_wait = set_label("peerPingWait");
|
|
86
|
+
QLabel* addr_relay = set_label("peerAddrRelayEnabled");
|
|
87
|
+
QLabel* addr_processed = set_label("peerAddrProcessed");
|
|
88
|
+
QLabel* addr_rate_limited = set_label("peerAddrRateLimited");
|
|
89
|
+
QLabel* relay_txs = set_label("peerRelayTxes");
|
|
90
|
+
|
|
91
|
+
QVERIFY(time_offset);
|
|
92
|
+
QVERIFY(services);
|
|
93
|
+
QVERIFY(sync_height);
|
|
94
|
+
QVERIFY(common_height);
|
|
95
|
+
QVERIFY(starting_height);
|
|
96
|
+
QVERIFY(ping_wait);
|
|
97
|
+
QVERIFY(addr_relay);
|
|
98
|
+
QVERIFY(addr_processed);
|
|
99
|
+
QVERIFY(addr_rate_limited);
|
|
100
|
+
QVERIFY(relay_txs);
|
|
101
|
+
QVERIFY(QMetaObject::invokeMethod(console, "resetPeerStateStats"));
|
|
102
|
+
QCOMPARE(time_offset->text(), QStringLiteral("N/A"));
|
|
103
|
+
QCOMPARE(services->text(), QStringLiteral("N/A"));
|
|
104
|
+
QCOMPARE(sync_height->text(), QStringLiteral("Unknown"));
|
|
105
|
+
QCOMPARE(common_height->text(), QStringLiteral("Unknown"));
|
|
106
|
+
QCOMPARE(starting_height->text(), QStringLiteral("Unknown"));
|
|
107
|
+
QCOMPARE(ping_wait->text(), QStringLiteral("N/A"));
|
|
108
|
+
QCOMPARE(addr_relay->text(), QStringLiteral("N/A"));
|
|
109
|
+
QCOMPARE(addr_processed->text(), QStringLiteral("N/A"));
|
|
110
|
+
QCOMPARE(addr_rate_limited->text(), QStringLiteral("N/A"));
|
|
111
|
+
QCOMPARE(relay_txs->text(), QStringLiteral("N/A"));
|
|
112
|
+
}
|
|
113
|
+
|
|
57
114
|
void TestQrQuietZone()
|
|
58
115
|
{
|
|
59
116
|
#ifdef USE_QRCODE
|
|
@@ -128,6 +185,7 @@ void AppTests::consoleTests(RPCConsole* console)
|
|
|
128
185
|
{
|
|
129
186
|
HandleCallback callback{"consoleTests", *this};
|
|
130
187
|
TestRpcCommand(console);
|
|
188
|
+
TestPeerRefreshState(console);
|
|
131
189
|
}
|
|
132
190
|
|
|
133
191
|
//! Destructor to shut down after the last expected callback completes.
|