settlekit/packages/app-kit/test/validate.test.ts
caelum0x 9d2bc4eae0 feat(arc/circle): ERC-8004 + ERC-8183 + arc-chains, swap-fee + DCW contract-exec
New packages (port/adapter pattern, zero new external deps, deterministic local impls + tests):
- @settlekit/erc8004: agent identity / reputation / validation on Arc (real Arc Testnet registry addresses); AgentRegistryClient + LocalErc8004Port.
- @settlekit/erc8183: autonomous-agent job lifecycle (create→fund→submit→evaluate→settle/refund) as a validated state machine; JobClient + LocalErc8183Port.
- @settlekit/arc-chains: single source of truth for Arc/Circle chain + token + contract constants.

Extensions:
- app-kit swap: slippage tolerance + custom swap-fee collection (Stablecoin-FX monetization), validateBps, LocalAppKitSdk.lastSwapConfig().
- circle-wallets: Developer-Controlled-Wallet contract execution + transaction polling (drives ERC-8004/8183 on-chain).

1130 tests across 192 suites, typecheck + full build green.
2026-06-20 19:08:41 +03:00

32 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { validateBps } from "../src/index.js";
describe("validateBps", () => {
it("accepts the inclusive 0..10000 integer range", () => {
for (const value of [0, 1, 50, 5000, 10000]) {
expect(validateBps(value, "bps")).toBeNull();
}
});
it("rejects values outside the range", () => {
for (const value of [-1, 10001, 99999]) {
const error = validateBps(value, "bps");
expect(error).not.toBeNull();
expect(error?.code).toBe("validation_error");
}
});
it("rejects non-integers including NaN and Infinity", () => {
for (const value of [1.5, 12.3, Number.NaN, Number.POSITIVE_INFINITY]) {
const error = validateBps(value, "bps");
expect(error).not.toBeNull();
expect(error?.code).toBe("validation_error");
}
});
it("includes the field name in the error details", () => {
const error = validateBps(-1, "slippageBps");
expect(error?.details).toMatchObject({ field: "slippageBps", value: -1 });
});
});