mirror of
https://github.com/logos-co/logos-protocol.git
synced 2026-08-27 20:11:07 +00:00
* Extract the Logos protocol layer from logos-cpp-sdk
Transports (plain TCP/TLS, qt_local, qt_remote/QRO, mock), token manager,
consumer core (LogosAPIClient/LogosAPIConsumer incl. the capability
auto-requestModule flow), ModuleProxy, the abstract LogosProviderObject
interface, and the canonical QVariant<->JSON conversion — now behind the
language-neutral lp_* C ABI (logos_protocol.h) carrying the protocol
semver (LOGOS_PROTOCOL_VERSION_*, lp_protocol_version()).
Bytes crossing the ABI use the lossless {"_bytes": base64url} tagging
(NUL-safe), matching the plain wire encoding.
Provider lp_* surface is compiled groundwork; serving lands with module
authoring.
* consumer: typed requestModule for the capability flow
Port of logos-cpp-sdk master f5a127dd ('use updated capability module',
cpp-sdk#85, Iuri Matias) — the touched files (logos_api_client.cpp,
logos_api_consumer.{h,cpp}) moved into this repo in the P1 extraction.
The capability auto-requestModule path now calls a typed std::string
helper on the consumer (which acquires the capability object directly)
instead of a stringly invokeRemoteMethod round-trip. 111/111 tests.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#include <gtest/gtest.h>
|
|
#include "logos_instance.h"
|
|
|
|
class LogosInstanceTest : public ::testing::Test {
|
|
protected:
|
|
void SetUp() override
|
|
{
|
|
// Clear env so we get a fresh ID
|
|
qunsetenv("LOGOS_INSTANCE_ID");
|
|
}
|
|
void TearDown() override
|
|
{
|
|
qunsetenv("LOGOS_INSTANCE_ID");
|
|
}
|
|
};
|
|
|
|
TEST_F(LogosInstanceTest, IdReturnsNonEmpty)
|
|
{
|
|
QString id = LogosInstance::id();
|
|
EXPECT_FALSE(id.isEmpty());
|
|
}
|
|
|
|
TEST_F(LogosInstanceTest, IdIs12Chars)
|
|
{
|
|
QString id = LogosInstance::id();
|
|
EXPECT_EQ(id.length(), 12);
|
|
}
|
|
|
|
TEST_F(LogosInstanceTest, IdIsStableAcrossCalls)
|
|
{
|
|
QString id1 = LogosInstance::id();
|
|
QString id2 = LogosInstance::id();
|
|
EXPECT_EQ(id1, id2);
|
|
}
|
|
|
|
TEST_F(LogosInstanceTest, IdSetsEnvVar)
|
|
{
|
|
QString id = LogosInstance::id();
|
|
QByteArray env = qgetenv("LOGOS_INSTANCE_ID");
|
|
EXPECT_EQ(QString::fromUtf8(env), id);
|
|
}
|
|
|
|
TEST_F(LogosInstanceTest, IdRespectsExistingEnvVar)
|
|
{
|
|
qputenv("LOGOS_INSTANCE_ID", "custom_id_123");
|
|
QString id = LogosInstance::id();
|
|
EXPECT_EQ(id, "custom_id_123");
|
|
}
|
|
|
|
TEST_F(LogosInstanceTest, RegistryUrlFormat)
|
|
{
|
|
qputenv("LOGOS_INSTANCE_ID", "abc123def456");
|
|
QString url = LogosInstance::id("my_module");
|
|
EXPECT_EQ(url, "local:logos_my_module_abc123def456");
|
|
}
|