Skip to content

Commit 6969b2b

Browse files
committed
qt, test: use regex search in apptests
use the FindInConsole function to regex search for values in apptests instead of Univalue read.
1 parent d09d1cf commit 6969b2b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/qt/test/apptests.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <qt/rpcconsole.h>
1313
#include <shutdown.h>
1414
#include <test/util/setup_common.h>
15-
#include <univalue.h>
1615
#include <validation.h>
1716

1817
#if defined(HAVE_CONFIG_H)
@@ -24,6 +23,7 @@
2423
#include <QRegularExpression>
2524
#include <QScopedPointer>
2625
#include <QSignalSpy>
26+
#include <QString>
2727
#include <QTest>
2828
#include <QTextEdit>
2929
#include <QtGlobal>
@@ -49,10 +49,9 @@ void TestRpcCommand(RPCConsole* console)
4949
QTest::keyClick(lineEdit, Qt::Key_Return);
5050
QVERIFY(mw_spy.wait(1000));
5151
QCOMPARE(mw_spy.count(), 4);
52-
QString output = messagesWidget->toPlainText();
53-
UniValue value;
54-
value.read(output.right(output.size() - output.lastIndexOf(QChar::ObjectReplacementCharacter) - 1).toStdString());
55-
QCOMPARE(value["chain"].get_str(), std::string("regtest"));
52+
const QString output = messagesWidget->toPlainText();
53+
const QString pattern = QStringLiteral("\"chain\": \"(\\w+)\"");
54+
QCOMPARE(FindInConsole(output, pattern), QString("regtest"));
5655
}
5756
} // namespace
5857

0 commit comments

Comments
 (0)