Initial commit: USDT transfer worker (RabbitMQ + Postgres + Vault)

This commit is contained in:
ZOMBIIIIIII
2026-04-30 20:00:21 +03:00
commit f250b99288
24 changed files with 3283 additions and 0 deletions

24
tests/amount.test.ts Normal file
View File

@@ -0,0 +1,24 @@
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { formatUsdtAmount, parseUsdtAmount } from "../src/domain/amount.js";
void describe("USDT amount parsing", () => {
void it("parses whole and fractional USDT with 6 decimals", () => {
assert.equal(parseUsdtAmount("1"), 1_000_000n);
assert.equal(parseUsdtAmount("1.234567"), 1_234_567n);
assert.equal(parseUsdtAmount("0.000001"), 1n);
});
void it("rejects zero, negative, malformed, and over-precise values", () => {
assert.throws(() => parseUsdtAmount("0"), /greater than zero/);
assert.throws(() => parseUsdtAmount("-1"), /valid decimal/);
assert.throws(() => parseUsdtAmount("1.0000001"), /at most 6 decimals/);
assert.throws(() => parseUsdtAmount("1e3"), /valid decimal/);
});
void it("formats raw token units back to a trimmed USDT string", () => {
assert.equal(formatUsdtAmount(1_234_567n), "1.234567");
assert.equal(formatUsdtAmount(1_000_000n), "1");
assert.equal(formatUsdtAmount(10n), "0.00001");
});
});