Skip to content

Commit

Permalink
QT tests and optimization of the warning messages adding function
Browse files Browse the repository at this point in the history
  • Loading branch information
levoncrypto committed Jun 9, 2024
1 parent 39d6fbf commit 4fc081a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/qt/sendcoinsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "optionsmodel.h"
#include "platformstyle.h"
#include "walletmodel.h"
#include "../wallet/wallet.h"

#include <QApplication>
#include <QClipboard>
Expand Down Expand Up @@ -140,23 +141,22 @@ QString SendCoinsEntry::generateWarningText(const QString& address, const bool f
warningText = tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address.");
} else {
if (!fAnonymousMode) {
if (model->validateAddress(address)) {
if (pwalletMain->validateAddress(address.toStdString())) {
warningText = tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead.");
} else if (model->validateSparkAddress(address)) {
} else if (pwalletMain->validateSparkAddress(address.toStdString())) {
warningText = tr(" You are sending Firo from a transparent address to a Spark address.");
}
} else {
if (model->validateSparkAddress(address)) {
if (pwalletMain->validateSparkAddress(address.toStdString())) {
warningText = tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private.");
} else if (model->validateAddress(address)) {
} else if (pwalletMain->validateAddress(address.toStdString())) {
warningText = tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits.");
}
}
}
return warningText;
}


bool SendCoinsEntry::validate()
{
if (!model)
Expand Down
6 changes: 3 additions & 3 deletions src/qt/sendcoinsentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class SendCoinsEntry : public QStackedWidget
QWidget *setupTabChain(QWidget *prev);

void setFocus();
void setWarning(const bool fAnonymousMode);
void setWarning(bool fAnonymousMode);
void setfAnonymousMode(bool fAnonymousMode);
QString generateWarningText(const QString& address, const bool fAnonymousMode);
static QString generateWarningText(const QString& address, const bool fAnonymousMode);

public Q_SLOTS:
void clear();
Expand All @@ -73,7 +73,7 @@ private Q_SLOTS:
WalletModel *model;
const PlatformStyle *platformStyle;
bool isPcodeEntry;
bool fAnonymousMode;
bool fAnonymousMode = false;
bool updateLabel(const QString &address);
};

Expand Down
12 changes: 7 additions & 5 deletions src/qt/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ int main(int argc, char *argv[])

SSL_library_init();

TestSendCoinsEntry test1;
URITests test1;
if (QTest::qExec(&test1) != 0)
fInvalid = true;

URITests test2;
TestSendCoinsEntry test2;
if (QTest::qExec(&test2) != 0)
fInvalid = true;
RPCNestedTests test3;
if (QTest::qExec(&test3) != 0)
fInvalid = true;

// RPCNestedTests test3;
// if (QTest::qExec(&test3) != 0)
// fInvalid = true;

CompatTests test4;
if (QTest::qExec(&test4) != 0)
fInvalid = true;
Expand Down
11 changes: 5 additions & 6 deletions src/qt/test/test_sendcoinsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

void TestSendCoinsEntry::testGenerateWarningText()
{
SendCoinsEntry* entry;
QCOMPARE(entry->generateWarningText("EXRSxX8yJHudk4QswGf3N5aPVTUi5Q1ZdX56", false), QObject::tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."));
QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", false), QObject::tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."));
QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", false), QObject::tr(" You are sending Firo from a transparent address to a Spark address."));
QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", true), QObject::tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."));
QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", true), QObject::tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."));
QCOMPARE(SendCoinsEntry::generateWarningText("EXRSxX8yJHudk4QswGf3N5aPVTUi5Q1ZdX56", false), QObject::tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."));
QCOMPARE(SendCoinsEntry::generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", false), QObject::tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."));
QCOMPARE(SendCoinsEntry::generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", false), QObject::tr(" You are sending Firo from a transparent address to a Spark address."));
QCOMPARE(SendCoinsEntry::generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", true), QObject::tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."));
QCOMPARE(SendCoinsEntry::generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", true), QObject::tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."));
}
2 changes: 1 addition & 1 deletion src/qt/test/uritests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void URITests::uriTests()
QVERIFY(rv.address == QString("MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs"));
QVERIFY(rv.label == QString());

QVERIFY(GUIUtil::parseBitcoinURI("firo://MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs?message=Wikipedia Example Address", &rv));
QVERIFY(GUIUtil::parseBitcoinURI("firo:MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs?message=Wikipedia Example Address", &rv));
QVERIFY(rv.address == QString("MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs"));
QVERIFY(rv.label == QString());

Expand Down

0 comments on commit 4fc081a

Please sign in to comment.