feat(device-plane): add typed B2 service ping transport
This commit is contained in:
@@ -7,8 +7,10 @@ import {
|
||||
assertB2ProfileInvariant,
|
||||
buildB2HeaderAcknowledgement,
|
||||
buildB2PackageAcknowledgement,
|
||||
buildB2TypedCommand,
|
||||
tryParseB2Header2,
|
||||
tryParseB2Package,
|
||||
tryParseB2TypedCommandResponse,
|
||||
} from "../src/index.mjs";
|
||||
|
||||
const specificationHeader = Buffer.from(
|
||||
@@ -131,10 +133,32 @@ test("fails closed on unsupported headers and malformed packages", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("exports no command builder and keeps transport disabled", () => {
|
||||
assert.equal(ARUSNAVI_B2_MODEL_PROFILE.commandTransport.status, "disabled");
|
||||
test("exports only the typed service-ping command", () => {
|
||||
assert.equal(
|
||||
ARUSNAVI_B2_MODEL_PROFILE.commandTransport.status,
|
||||
"typed-service-ping-v1",
|
||||
);
|
||||
assert.equal(
|
||||
ARUSNAVI_B2_MODEL_PROFILE.commandTransport.exportedCommandBuilders,
|
||||
0,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
buildB2TypedCommand({ commandType: "service.ping", accessCode: "123456" })
|
||||
.toString("ascii"),
|
||||
"123456*SERV*1.1",
|
||||
);
|
||||
assert.deepEqual(
|
||||
tryParseB2TypedCommandResponse(Buffer.from("SERV OK", "ascii"), {
|
||||
commandType: "service.ping",
|
||||
}),
|
||||
{ status: "acknowledged", bytesConsumed: 7, resultCode: "serv_ok" },
|
||||
);
|
||||
assert.throws(
|
||||
() => buildB2TypedCommand({ commandType: "service.ping", accessCode: "12345" }),
|
||||
/b2_command_access_code_invalid/,
|
||||
);
|
||||
assert.throws(
|
||||
() => buildB2TypedCommand({ commandType: "firmware.update", accessCode: "123456" }),
|
||||
/b2_typed_command_unsupported/,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user