Files
logos-messaging-module/test/test_create_node_integration.cpp
fryorcrakenandClaude Opus 4.7 1fde156629 flake: backport externalLibInputs fix for tutorial-v1 compat
Re-forked from tag 1.0.0 (256eca02), which is the commit that ships
inside logos-basecamp AppImage v0.1.1. Starting from 1.0.0 (instead of
6eeda84) means the tutorial-v1-compat LGX unambiguously reproduces the
delivery_module shipped by basecamp -- lifecycle RPCs (createNode,
start, stop, subscribe, unsubscribe) return plain bool on the wire,
send() returns LogosResult, and the implementation matches what
basecamp actually calls into.

Tag 1.0.0 predates the logos-module-builder migration, so this commit
overlays the minimum set of module-builder packaging artifacts
required to build the module as an LGX:

  * CMakeLists.txt -- replaced with the mkLogosModule-style build that
    delegates to LogosModule.cmake. Sources were moved to src/ to
    match the convention.
  * metadata.json -- extended with the nix.external_libraries block
    required by module-builder.
  * flake.nix / flake.lock -- introduced (1.0.0 used a bespoke ./nix/
    builder with vendored submodules, which no longer matches the
    downstream module-builder toolchain).
  * test/test_create_node_integration.cpp -- brought over from the
    newer tree. It compiles against the 1.0.0 plugin API, though the
    createNode_secondCallRejected_afterSuccessfulInit case asserts
    behaviour that only exists post-1.0.0; tests are gated on
    BUILD_TESTING and are not exercised by the portable LGX build.

On top of that the externalLibInputs fix that was previously the tip
of this branch is re-applied:

  * flake.nix: externalLibInputs = { logosdelivery = { input = ...;
    packages.default = "liblogosdelivery"; }; } (new shape).
  * metadata.json: nix.external_libraries[].name = "logosdelivery" to
    match.
  * logos-delivery pinned to 509c8755 so liblogosdelivery.so lands in
    $out/lib/ instead of $out/bin/, which module-builder's copy logic
    requires.

src/ is the verbatim 1.0.0 source. Wire-level RPC signatures were
verified byte-identical to 6eeda84 prior to this rebase (same
Q_INVOKABLE set, same types; only internal createNode reentrancy
changes differ).

Refs: logos-co/logos-delivery-module#22

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 12:13:33 +10:00

153 lines
4.1 KiB
C++

#include <QtTest/QtTest>
#include <QElapsedTimer>
#include <QLibrary>
#include "delivery_module_plugin.h"
class DeliveryModulePluginCreateNodeIntegrationTest : public QObject
{
Q_OBJECT
private:
static const QString kDefaultConfig;
static const QString kEdgeConfig;
static const QString kCoreConfig;
static bool hasLibpqDependency()
{
const QStringList candidates = {
QStringLiteral("libpq"),
QStringLiteral("libpq.dylib"),
QStringLiteral("pq")
};
for (const QString& candidate : candidates) {
QLibrary library(candidate);
if (library.load()) {
library.unload();
return true;
}
}
return false;
}
private slots:
void createNode_withDefaultConfig_succeedsOrSkips();
void createNode_withEdgeConfig_succeedsOrSkips();
void createNode_withCoreConfig_succeedsOrSkips();
void createNode_secondCallRejected_afterSuccessfulInit();
void startStop_withRealBackend_succeedsOrSkips();
};
const QString DeliveryModulePluginCreateNodeIntegrationTest::kDefaultConfig = QStringLiteral("{}");
const QString DeliveryModulePluginCreateNodeIntegrationTest::kEdgeConfig = QStringLiteral(R"JSON({
"mode": "Edge",
"protocolsConfig": {
"entryNodes": [],
"clusterId": 1,
"messageValidation": {
"maxMessageSize": "150 KiB",
"rlnConfig": null
}
},
"networkingConfig": {
"listenIpv4": "127.0.0.1",
"p2pTcpPort": 61000,
"discv5UdpPort": 61001
},
"ethRpcEndpoints": [],
"p2pReliability": false,
"logLevel": "INFO",
"logFormat": "TEXT"
})JSON");
const QString DeliveryModulePluginCreateNodeIntegrationTest::kCoreConfig = QStringLiteral(R"JSON({
"mode": "Core",
"protocolsConfig": {
"entryNodes": [],
"clusterId": 1,
"autoShardingConfig": {
"numShardsInCluster": 1
},
"messageValidation": {
"maxMessageSize": "150 KiB",
"rlnConfig": null
}
},
"networkingConfig": {
"listenIpv4": "127.0.0.1",
"p2pTcpPort": 62000,
"discv5UdpPort": 62001
},
"ethRpcEndpoints": [],
"p2pReliability": false,
"logLevel": "INFO",
"logFormat": "TEXT"
})JSON");
void DeliveryModulePluginCreateNodeIntegrationTest::createNode_withDefaultConfig_succeedsOrSkips()
{
if (!hasLibpqDependency()) {
QSKIP("libpq dynamic library is not available; skipping logosdelivery integration test.");
}
DeliveryModulePlugin plugin;
QVERIFY(plugin.createNode(kDefaultConfig));
}
void DeliveryModulePluginCreateNodeIntegrationTest::createNode_withEdgeConfig_succeedsOrSkips()
{
if (!hasLibpqDependency()) {
QSKIP("libpq dynamic library is not available; skipping logosdelivery integration test.");
}
DeliveryModulePlugin plugin;
QVERIFY(plugin.createNode(kEdgeConfig));
}
void DeliveryModulePluginCreateNodeIntegrationTest::createNode_withCoreConfig_succeedsOrSkips()
{
if (!hasLibpqDependency()) {
QSKIP("libpq dynamic library is not available; skipping logosdelivery integration test.");
}
DeliveryModulePlugin plugin;
QElapsedTimer timer;
timer.start();
QVERIFY(plugin.createNode(kCoreConfig));
}
void DeliveryModulePluginCreateNodeIntegrationTest::createNode_secondCallRejected_afterSuccessfulInit()
{
if (!hasLibpqDependency()) {
QSKIP("libpq dynamic library is not available; skipping logosdelivery integration test.");
}
DeliveryModulePlugin plugin;
QVERIFY(plugin.createNode(kEdgeConfig));
QVERIFY(!plugin.createNode(kEdgeConfig));
}
void DeliveryModulePluginCreateNodeIntegrationTest::startStop_withRealBackend_succeedsOrSkips()
{
if (!hasLibpqDependency()) {
QSKIP("libpq dynamic library is not available; skipping logosdelivery integration test.");
}
DeliveryModulePlugin plugin;
QVERIFY(plugin.createNode(kEdgeConfig));
QVERIFY(plugin.start());
QVERIFY(plugin.stop());
}
QTEST_MAIN(DeliveryModulePluginCreateNodeIntegrationTest)
#include "test_create_node_integration.moc"