mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 14:11:09 +00:00
feat(amm-ui): complete new position liquidity flow
Implement one create-pool and add-liquidity workflow. Add searchable token resolution, direct opening-price and deposit editing, optimistic pool activation, and base58 transaction IDs. Isolate network, wallet, AMM client, and runtime boundaries. Stabilize quote, submission, refresh, and pool-probe state while consolidating liquidity tests and removing obsolete liquidity paths.
This commit is contained in:
@@ -4,44 +4,62 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QTemporaryFile>
|
||||
#include <QtTest>
|
||||
|
||||
class ActiveNetworkTest : public QObject {
|
||||
Q_OBJECT
|
||||
namespace {
|
||||
bool expect(bool condition, const char* message)
|
||||
{
|
||||
if (!condition)
|
||||
qCritical("%s", message);
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
||||
private slots:
|
||||
void validatesIdentityBeforeReadiness();
|
||||
};
|
||||
|
||||
void ActiveNetworkTest::validatesIdentityBeforeReadiness()
|
||||
int main()
|
||||
{
|
||||
const QString identity(64, QLatin1Char('a'));
|
||||
const QString programId(64, QLatin1Char('b'));
|
||||
const QString tokenId(64, QLatin1Char('c'));
|
||||
|
||||
QTemporaryFile config;
|
||||
QVERIFY(config.open());
|
||||
if (!config.open())
|
||||
return 1;
|
||||
config.write(QJsonDocument(QJsonObject {
|
||||
{ QStringLiteral("channelId"), identity },
|
||||
{ QStringLiteral("ammProgramId"), programId },
|
||||
{ QStringLiteral("tokenDefinitionIds"), QJsonArray { tokenId } },
|
||||
}).toJson(QJsonDocument::Compact));
|
||||
config.flush();
|
||||
|
||||
qputenv("AMM_UI_NETWORK", "devnet");
|
||||
qputenv("AMM_UI_DEVNET_FILE", config.fileName().toLocal8Bit());
|
||||
|
||||
ActiveNetwork network;
|
||||
QVERIFY(network.load());
|
||||
QCOMPARE(network.status(), QStringLiteral("network_unknown"));
|
||||
if (!expect(network.load(), "devnet config should load"))
|
||||
return 1;
|
||||
if (!expect(network.snapshot().status == QStringLiteral("network_unknown"),
|
||||
"loaded network should await identity"))
|
||||
return 1;
|
||||
|
||||
network.sequencerChanged(true);
|
||||
network.finishIdentityProbe(QString(64, QLatin1Char('d')));
|
||||
QCOMPARE(network.status(), QStringLiteral("network_mismatch"));
|
||||
if (!expect(network.status() == QStringLiteral("network_mismatch"),
|
||||
"wrong identity should block the network"))
|
||||
return 1;
|
||||
|
||||
network.reachabilityChanged(false, true);
|
||||
network.reachabilityChanged(true, false);
|
||||
network.finishIdentityProbe(identity);
|
||||
QCOMPARE(network.status(), QStringLiteral("ready"));
|
||||
QCOMPARE(network.snapshot().fingerprint, QStringLiteral("channel:") + identity);
|
||||
QCOMPARE(network.snapshot().tokenIds, QStringList { tokenId });
|
||||
}
|
||||
const ActiveNetworkSnapshot snapshot = network.snapshot();
|
||||
if (!expect(snapshot.status == QStringLiteral("ready"),
|
||||
"matching identity should ready the network"))
|
||||
return 1;
|
||||
if (!expect(snapshot.fingerprint == QStringLiteral("channel:") + identity,
|
||||
"devnet fingerprint should use channel identity"))
|
||||
return 1;
|
||||
if (!expect(snapshot.ammProgramId == programId
|
||||
&& snapshot.tokenIds == QStringList { tokenId },
|
||||
"network snapshot should preserve configured program and tokens"))
|
||||
return 1;
|
||||
|
||||
QTEST_GUILESS_MAIN(ActiveNetworkTest)
|
||||
#include "ActiveNetworkTest.moc"
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user