import { describe, it, expect } from 'vitest'; import { GroupSecret } from '../src/identity'; import { bytesToHex } from '../src/parser'; describe('GroupSecret.fromName', () => { it('computes Public secret correctly', () => { const g = GroupSecret.fromName('Public'); expect(bytesToHex(g.secret)).toBe('8b3387e9c5cdea6ac9e5edbaa115cd72'); }); it('computes #test secret correctly', () => { const g = GroupSecret.fromName('#test'); expect(bytesToHex(g.secret)).toBe('9cd8fcf22a47333b591d96a2b848b73f'); }); it('throws for invalid names', () => { expect(() => GroupSecret.fromName('foo')).toThrow(); }); it('accepts single # and returns 16 bytes', () => { const g = GroupSecret.fromName('#'); expect(g.secret).toBeInstanceOf(Uint8Array); expect(g.secret.length).toBe(16); }); it('returns GroupSecret instances consistently', () => { const a = GroupSecret.fromName('#abc'); const b = GroupSecret.fromName('#abc'); expect(bytesToHex(a.secret)).toBe(bytesToHex(b.secret)); }); });