mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: enhance order handling in LighterGateway and introduce order identity normalization for improved precision and consistency
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user