-
Notifications
You must be signed in to change notification settings - Fork 0
Fix GMCP error caused by forwarding External.Discord.Get to MUME #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,12 @@ void TestProxy::gmcpMessageDeserializeTest() | |
| GmcpMessage gmcp3 = GmcpMessage::fromRawBytes(R"(External.Discord.Hello)"); | ||
| QCOMPARE(gmcp3.getName().toQByteArray(), QByteArray("External.Discord.Hello")); | ||
| QVERIFY(!gmcp3.getJson()); | ||
| QVERIFY(gmcp3.isExternalDiscordHello()); | ||
|
|
||
| GmcpMessage gmcp4 = GmcpMessage::fromRawBytes(R"(External.Discord.Get)"); | ||
| QCOMPARE(gmcp4.getName().toQByteArray(), QByteArray("External.Discord.Get")); | ||
| QVERIFY(!gmcp4.getJson()); | ||
| QVERIFY(gmcp4.isExternalDiscordGet()); | ||
|
Comment on lines
+39
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Add a test that verifies Right now the tests only cover GMCP deserialization and Suggested implementation: GmcpMessage gmcp4 = GmcpMessage::fromRawBytes(R"(External.Discord.Get)");
QCOMPARE(gmcp4.getName().toQByteArray(), QByteArray("External.Discord.Get"));
QVERIFY(!gmcp4.getJson());
QVERIFY(gmcp4.isExternalDiscordGet());
}
void TestProxy::externalDiscordGetIsEatenByUserTelnet()
{
// Arrange: set up a UserTelnet instance wired through the proxy test harness.
// This should follow the same pattern as other tests that exercise
// UserTelnet::virt_receiveGmcpMessage in this file.
UserTelnet *userTelnet = /* obtain from existing fixture or create as in other tests */;
QVERIFY(userTelnet);
// Use the same mechanism other tests use to observe writes to the MUME side
// and GMCP errors (typically QSignalSpy on the appropriate signals).
QSignalSpy mumeWriteSpy(userTelnet, SIGNAL(writeMume(QByteArray)));
QSignalSpy gmcpErrorSpy(userTelnet, SIGNAL(gmcpError(QString)));
// Act: deliver an External.Discord.Get GMCP message to virt_receiveGmcpMessage.
GmcpMessage gmcpGet = GmcpMessage::fromRawBytes(R"(External.Discord.Get)");
userTelnet->virt_receiveGmcpMessage(gmcpGet);
// Assert: the message is eaten, no downstream handling and no error.
QCOMPARE(mumeWriteSpy.count(), 0);
QCOMPARE(gmcpErrorSpy.count(), 0);
}
void TestProxy::gmcpMessageSerializeTest()
|
||
| } | ||
|
|
||
| void TestProxy::gmcpMessageSerializeTest() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add corresponding serialize test for
External.Discord.Getto keep deserialize/serialize coverage symmetric.To fully validate the new GMCP type wiring, please also add a
gmcpMessageSerializeTestcase that builds aGmcpMessageof typeExternalDiscordGet, serializes it, and verifies the raw bytes (including the name and absence of JSON). This keeps deserialize/serialize tests symmetric and will help catch regressions if the enum or name mapping changes.Suggested implementation:
To correctly integrate this change without overwriting existing tests, please:
GmcpMessage gmcpExternalDiscordGetblock into the existing body ofgmcpMessageSerializeTest(), alongside the other serialize cases, instead of replacing the whole function. Place it near the serialize test forExternal.Discord.Helloto keep the coverage grouped./* TODO: use the appropriate constructor or enum for ExternalDiscordGet */with the actual way you construct aGmcpMessageof typeExternalDiscordGetin your codebase (for example, using the corresponding enum or factory method already used forExternalDiscordHelloin the serialize tests).toRawBytes()(e.g.serialize()or similar), update the call accordingly so that the comparison verifies the exact raw GMCP bytes, matching the format used in the deserialize tests.