aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2021-03-02 07:47:57 -0500
committerRussell Yanofsky <russ@yanofsky.org>2021-03-03 09:19:35 -0500
commit985430d9b2e183c1f59a34472e413a8d00a7e6da (patch)
tree490e87feb8f8f6b51f00d48315da00787c8aa64d /src/qt/test
parentcabe63759ce890a7d39d72f7b8046195b0edb421 (diff)
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 <jarolrod@tutanota.com>
Diffstat (limited to 'src/qt/test')
-rw-r--r--src/qt/test/wallettests.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
index d6d2d0e3df..0ef1fb318a 100644
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -225,6 +225,7 @@ void TestGUI(interfaces::Node& node)
int initialRowCount = requestTableModel->rowCount({});
QPushButton* requestPaymentButton = receiveCoinsDialog.findChild<QPushButton*>("receiveButton");
requestPaymentButton->click();
+ QString address;
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("ReceiveRequestDialog")) {
ReceiveRequestDialog* receiveRequestDialog = qobject_cast<ReceiveRequestDialog*>(widget);
@@ -233,6 +234,9 @@ void TestGUI(interfaces::Node& node)
QString uri = receiveRequestDialog->QObject::findChild<QLabel*>("uri_content")->text();
QCOMPARE(uri.count("bitcoin:"), 2);
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("address_tag")->text(), QString("Address:"));
+ QVERIFY(address.isEmpty());
+ address = receiveRequestDialog->QObject::findChild<QLabel*>("address_content")->text();
+ QVERIFY(!address.isEmpty());
QCOMPARE(uri.count("amount=0.00000001"), 2);
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("amount_tag")->text(), QString("Amount:"));
@@ -259,12 +263,30 @@ void TestGUI(interfaces::Node& node)
int currentRowCount = requestTableModel->rowCount({});
QCOMPARE(currentRowCount, initialRowCount+1);
+ // Check addition to wallet
+ std::vector<std::string> requests = walletModel.wallet().getDestValues("rr");
+ QCOMPARE(requests.size(), size_t{1});
+ RecentRequestEntry entry;
+ CDataStream{MakeUCharSpan(requests[0]), SER_DISK, CLIENT_VERSION} >> entry;
+ QCOMPARE(entry.nVersion, int{1});
+ QCOMPARE(entry.id, int64_t{1});
+ QVERIFY(entry.date.isValid());
+ QCOMPARE(entry.recipient.address, address);
+ QCOMPARE(entry.recipient.label, QString{"TEST_LABEL_1"});
+ QCOMPARE(entry.recipient.amount, CAmount{1});
+ QCOMPARE(entry.recipient.message, QString{"TEST_MESSAGE_1"});
+ QCOMPARE(entry.recipient.sPaymentRequest, std::string{});
+ QCOMPARE(entry.recipient.authenticatedMerchant, QString{});
+
// Check Remove button
QTableView* table = receiveCoinsDialog.findChild<QTableView*>("recentRequestsView");
table->selectRow(currentRowCount-1);
QPushButton* removeRequestButton = receiveCoinsDialog.findChild<QPushButton*>("removeRequestButton");
removeRequestButton->click();
QCOMPARE(requestTableModel->rowCount({}), currentRowCount-1);
+
+ // Check removal from wallet
+ QCOMPARE(walletModel.wallet().getDestValues("rr").size(), size_t{0});
}
} // namespace