feat: enhance order handling in LighterGateway and introduce order identity normalization for improved precision and consistency

This commit is contained in:
discountry
2025-11-12 19:17:04 +08:00
parent 1baee3a207
commit e7f6341961
11 changed files with 318 additions and 40 deletions
+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { normalizeOrderIdentity, orderIdentityEquals } from "../../src/exchanges/lighter/order-identity";
describe("order identity helpers", () => {
it("treats large numeric strings as distinct values", () => {
const first = "27584547724798440";
const second = "27584547724798442";
expect(orderIdentityEquals(first, second)).toBe(false);
expect(orderIdentityEquals(first, first)).toBe(true);
});
it("considers numeric inputs equal to their string counterparts", () => {
expect(orderIdentityEquals(123456789, "123456789")).toBe(true);
});
it("normalizes whitespace-only identifiers to null", () => {
expect(normalizeOrderIdentity(" ")).toBeNull();
});
it("falls back to truncated integers for floating inputs", () => {
expect(normalizeOrderIdentity(42.9)).toBe("42");
});
});