Skip to content

Commit 985430d

Browse files
ryanofskyjarolrod
andcommitted
test: Add gui test for wallet receive requests
Make sure wallet receive requests are saved and deleted correctly by GUI code Co-authored-by: Jarol Rodriguez <[email protected]>
1 parent cabe637 commit 985430d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/qt/test/wallettests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void TestGUI(interfaces::Node& node)
225225
int initialRowCount = requestTableModel->rowCount({});
226226
QPushButton* requestPaymentButton = receiveCoinsDialog.findChild<QPushButton*>("receiveButton");
227227
requestPaymentButton->click();
228+
QString address;
228229
for (QWidget* widget : QApplication::topLevelWidgets()) {
229230
if (widget->inherits("ReceiveRequestDialog")) {
230231
ReceiveRequestDialog* receiveRequestDialog = qobject_cast<ReceiveRequestDialog*>(widget);
@@ -233,6 +234,9 @@ void TestGUI(interfaces::Node& node)
233234
QString uri = receiveRequestDialog->QObject::findChild<QLabel*>("uri_content")->text();
234235
QCOMPARE(uri.count("bitcoin:"), 2);
235236
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("address_tag")->text(), QString("Address:"));
237+
QVERIFY(address.isEmpty());
238+
address = receiveRequestDialog->QObject::findChild<QLabel*>("address_content")->text();
239+
QVERIFY(!address.isEmpty());
236240

237241
QCOMPARE(uri.count("amount=0.00000001"), 2);
238242
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("amount_tag")->text(), QString("Amount:"));
@@ -259,12 +263,30 @@ void TestGUI(interfaces::Node& node)
259263
int currentRowCount = requestTableModel->rowCount({});
260264
QCOMPARE(currentRowCount, initialRowCount+1);
261265

266+
// Check addition to wallet
267+
std::vector<std::string> requests = walletModel.wallet().getDestValues("rr");
268+
QCOMPARE(requests.size(), size_t{1});
269+
RecentRequestEntry entry;
270+
CDataStream{MakeUCharSpan(requests[0]), SER_DISK, CLIENT_VERSION} >> entry;
271+
QCOMPARE(entry.nVersion, int{1});
272+
QCOMPARE(entry.id, int64_t{1});
273+
QVERIFY(entry.date.isValid());
274+
QCOMPARE(entry.recipient.address, address);
275+
QCOMPARE(entry.recipient.label, QString{"TEST_LABEL_1"});
276+
QCOMPARE(entry.recipient.amount, CAmount{1});
277+
QCOMPARE(entry.recipient.message, QString{"TEST_MESSAGE_1"});
278+
QCOMPARE(entry.recipient.sPaymentRequest, std::string{});
279+
QCOMPARE(entry.recipient.authenticatedMerchant, QString{});
280+
262281
// Check Remove button
263282
QTableView* table = receiveCoinsDialog.findChild<QTableView*>("recentRequestsView");
264283
table->selectRow(currentRowCount-1);
265284
QPushButton* removeRequestButton = receiveCoinsDialog.findChild<QPushButton*>("removeRequestButton");
266285
removeRequestButton->click();
267286
QCOMPARE(requestTableModel->rowCount({}), currentRowCount-1);
287+
288+
// Check removal from wallet
289+
QCOMPARE(walletModel.wallet().getDestValues("rr").size(), size_t{0});
268290
}
269291

270292
} // namespace

0 commit comments

Comments
 (0)