mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-03 05:22:49 +08:00
feat: add TS3 identity generation with Ed25519 keypairs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
bc89c553b7
commit
2b6e81119b
4 files changed
+73
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generateIdentity, exportIdentity, importIdentity } from "./identity.js";
|
||||
|
||||
describe("TS3 Identity", () => {
|
||||
it("generates a valid identity with keypair", () => {
|
||||
const identity = generateIdentity();
|
||||
expect(identity.publicKey).toBeInstanceOf(Uint8Array);
|
||||
expect(identity.privateKey).toBeInstanceOf(Uint8Array);
|
||||
expect(identity.publicKey.length).toBe(32);
|
||||
expect(identity.privateKey.length).toBe(64);
|
||||
expect(identity.uid).toBeTruthy();
|
||||
expect(typeof identity.uid).toBe("string");
|
||||
});
|
||||
|
||||
it("exports and imports identity consistently", () => {
|
||||
const identity = generateIdentity();
|
||||
const exported = exportIdentity(identity);
|
||||
const imported = importIdentity(exported);
|
||||
expect(imported.uid).toBe(identity.uid);
|
||||
expect(imported.publicKey).toEqual(identity.publicKey);
|
||||
});
|
||||
|
||||
it("generates unique identities each time", () => {
|
||||
const id1 = generateIdentity();
|
||||
const id2 = generateIdentity();
|
||||
expect(id1.uid).not.toBe(id2.uid);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user