"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SlugName_1 = require("@wireio/sdk-core/SlugName");
describe("SlugName", () => {
    describe("from", () => {
        // char[0] occupies the HIGH slot — bits [42..47] — mirroring
        // slug_name.hpp's most-significant-symbol-first packing.
        const SLOT0 = Math.pow(2, 42);
        const SLOT1 = Math.pow(2, 36);
        it("encodes single-letter strings (left-aligned: char[0] at bits 42..47)", () => {
            // 'A' is slot 1; first position
            expect(SlugName_1.SlugName.from("A")).toBe(1 * SLOT0);
            // 'Z' is slot 26
            expect(SlugName_1.SlugName.from("Z")).toBe(26 * SLOT0);
        });
        it("encodes digit '0' to slot 27", () => {
            expect(SlugName_1.SlugName.from("0")).toBe(27 * SLOT0);
        });
        it("encodes '_' to slot 37", () => {
            expect(SlugName_1.SlugName.from("_")).toBe(37 * SLOT0);
        });
        it("encodes a multi-char string with 6-bit MSB-first packing", () => {
            // "AB" → slot 1 at bits [42..47] + slot 2 at bits [36..41]
            expect(SlugName_1.SlugName.from("AB")).toBe(1 * SLOT0 + 2 * SLOT1);
        });
        it("matches the contract-side slug_name literals (KATs vs slug_name.hpp)", () => {
            // Known-answer values cross-checked against the depot's `"X"_s`
            // literals — `SlugName.from(s)` and the chain's packing are designed
            // to be byte-identical (user-confirmed 2026-06-12); these pins make
            // any future drift fail fast on both sides of the boundary.
            expect(SlugName_1.SlugName.from("WIRE")).toBe(101792956284928);
            expect(SlugName_1.SlugName.from("ETH")).toBe(23373212024832);
            expect(SlugName_1.SlugName.from("ETHEREUM")).toBe(23373300651341);
            expect(SlugName_1.SlugName.from("SOLANA")).toBe(84606581215232);
        });
        it("rejects empty input", () => {
            expect(() => SlugName_1.SlugName.from("")).toThrow(/empty/);
        });
        it("rejects strings longer than 8 chars", () => {
            expect(() => SlugName_1.SlugName.from("ABCDEFGHI")).toThrow(/longer than 8/);
        });
        it("rejects lowercase input", () => {
            expect(() => SlugName_1.SlugName.from("eth")).toThrow(/outside/);
        });
        it("rejects characters outside the alphabet", () => {
            expect(() => SlugName_1.SlugName.from("ETH!")).toThrow(/outside/);
            expect(() => SlugName_1.SlugName.from("E-T")).toThrow(/outside/);
        });
    });
    describe("toString", () => {
        const SLOT0 = Math.pow(2, 42);
        it("decodes 0 to empty string", () => {
            expect(SlugName_1.SlugName.toString(0)).toBe("");
        });
        it("decodes single-letter codes", () => {
            expect(SlugName_1.SlugName.toString(1 * SLOT0)).toBe("A");
            expect(SlugName_1.SlugName.toString(26 * SLOT0)).toBe("Z");
        });
        it("decodes digit slots", () => {
            expect(SlugName_1.SlugName.toString(27 * SLOT0)).toBe("0");
            expect(SlugName_1.SlugName.toString(36 * SLOT0)).toBe("9");
        });
        it("decodes underscore slot", () => {
            expect(SlugName_1.SlugName.toString(37 * SLOT0)).toBe("_");
        });
        it("decodes the contract-side literal values", () => {
            expect(SlugName_1.SlugName.toString(101792956284928)).toBe("WIRE");
            expect(SlugName_1.SlugName.toString(23373212024832)).toBe("ETH");
        });
    });
    describe("round-trip", () => {
        const inputs = ["ETH", "WIRE", "SOL", "USDC", "LIQETH", "LIQSOL", "PRIMARY", "ETHEREUM", "SOLANA", "0", "_", "A", "Z9_"];
        inputs.forEach(s => {
            it(`round-trips '${s}'`, () => {
                const encoded = SlugName_1.SlugName.from(s);
                expect(SlugName_1.SlugName.toString(encoded)).toBe(s);
            });
        });
        it("round-trips a max-length (8 char) code", () => {
            // 8 chars exactly — uses all 48 bits
            expect(SlugName_1.SlugName.toString(SlugName_1.SlugName.from("ABCDEFGH"))).toBe("ABCDEFGH");
        });
        it("encodes 'WIRE' and 'ETH' as distinct values", () => {
            expect(SlugName_1.SlugName.from("WIRE")).not.toBe(SlugName_1.SlugName.from("ETH"));
        });
    });
});
//# sourceMappingURL=SlugName.test.js.map