Handle unavailable cores and late status page responses
This commit is contained in:
1 parent
a96a5ae5ee
commit
e87972dea3
4 files changed
+74
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/* Desktop по умолчанию запускает core/chat; явный UTUN независим от создания TUN. */
|
||||
#include "../transport/utun_node.h"
|
||||
#include "../transport/gui_bridge.h"
|
||||
#include "../src/statuspage.h"
|
||||
#include <QtTest>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
@@ -219,6 +220,41 @@ private slots:
|
||||
QVERIFY(node.nodeIdHex().isEmpty() && !node.ntpSynced());
|
||||
}
|
||||
|
||||
void statusPageRefreshBeforeStartWhileRunningAndAfterStop() {
|
||||
QTemporaryDir directory; QVERIFY(directory.isValid());
|
||||
const QString path = directory.filePath("node.cfg");
|
||||
QFile config(path); QVERIFY(config.open(QIODevice::WriteOnly));
|
||||
const QByteArray text = "[global]\n" + identity +
|
||||
"[chatserver]\ngroup_autoconnect=0\nstorage_autoload=0\n[ntp]\nenabled=no\n";
|
||||
QCOMPARE(config.write(text), text.size()); config.close();
|
||||
UtunNode node;
|
||||
node.setDbPath(directory.filePath("db")); node.setDebugFile(directory.filePath("node.log"));
|
||||
StatusPage page(&node);
|
||||
auto* status = page.findChild<QPlainTextEdit*>(); QVERIFY(status);
|
||||
page.refreshStatus(); QCOMPARE(status->toPlainText(), QStringLiteral("Node is not running."));
|
||||
QVERIFY(node.start(path));
|
||||
page.refreshStatus();
|
||||
QTRY_VERIFY_WITH_TIMEOUT(status->toPlainText().contains("=== NTP ==="), 3000);
|
||||
QVERIFY(status->toPlainText().contains("=== Connections (0) ==="));
|
||||
node.stop();
|
||||
page.refreshStatus(); QCOMPARE(status->toPlainText(), QStringLiteral("Node is not running."));
|
||||
page.setText(QStringLiteral("late snapshot from stopped core"));
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(status->toPlainText(), QStringLiteral("Node is not running."));
|
||||
}
|
||||
|
||||
void statusPageSurvivesDeletedNodeAndUsesLocalClock() {
|
||||
auto* node = new UtunNode;
|
||||
StatusPage page(node);
|
||||
delete node;
|
||||
page.refreshStatus();
|
||||
auto* status = page.findChild<QPlainTextEdit*>(); QVERIFY(status);
|
||||
QCOMPARE(status->toPlainText(), QStringLiteral("Node is not running."));
|
||||
bool local = false;
|
||||
for (auto* label : page.findChildren<QLabel*>()) local |= label->text().contains("[LOCAL]");
|
||||
QVERIFY(local);
|
||||
}
|
||||
|
||||
#ifdef UTUN_TEST_NODE_STREAM_FAILURES
|
||||
void streamFailureRollsBackAndAllowsRetry_data() {
|
||||
QTest::addColumn<int>("stage");
|
||||
|
||||
Reference in new issue
Block a user