refactor: update romulus-js import path to @3t/romulus and adjust tests accordingly
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { encrypt, decrypt } from "romulus-js";
|
||||
import { encrypt, decrypt } from "@3t/romulus";
|
||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||
import { numberToUint16BE } from "../utilities/number";
|
||||
import { packOutgoingPacket } from "./packet";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Color from "color";
|
||||
import { encrypt } from "romulus-js";
|
||||
import { encrypt } from "@3t/romulus";
|
||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||
import { numberToUint16BE } from "../utilities/number";
|
||||
import { SmartBuffer } from "../utilities/smart-buffer";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Color from "color";
|
||||
import { encrypt } from "romulus-js";
|
||||
import { encrypt } from "@3t/romulus";
|
||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||
import { numberToUint16BE } from "../utilities/number";
|
||||
import { SmartBuffer } from "../utilities/smart-buffer";
|
||||
|
||||
@@ -26,12 +26,17 @@ test("Create a basic message (0x0001) packet.", () => {
|
||||
|
||||
test("Parse a basic message (0x0001).", () => {
|
||||
// Given
|
||||
const data = new Uint8Array([1, 2, 3, 4]);
|
||||
const encoder = new TextEncoder();
|
||||
const originalMessage = encoder.encode("Test message");
|
||||
|
||||
// First encrypt the message to get valid encrypted data
|
||||
const encryptedData = packers[MessageTypes.Basic](originalMessage, KEY);
|
||||
// Extract just the data portion (skip the 4-byte header)
|
||||
const dataOnly = encryptedData.slice(4);
|
||||
|
||||
// When
|
||||
const unpackedPacket = unpackers[MessageTypes.Basic](data);
|
||||
const unpackedMessage = unpackers[MessageTypes.Basic](dataOnly, KEY);
|
||||
|
||||
// Then
|
||||
expect(unpackedPacket);
|
||||
expect(unpackedPacket).toMatchObject(data);
|
||||
expect(unpackedMessage).toEqual(originalMessage);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user