import fs from "node:fs/promises"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { withStateDirEnv } from "../test-helpers/state-dir-env.js"; import { loadOrCreateDeviceIdentity } from "./device-identity.js";
describe("device identity state dir defaults", () => {
it("writes the default identity file under OPENCLAW_STATE_DIR", async () => {
await withStateDirEnv("openclaw-identity-state-", async ({ stateDir }) => { const identity = loadOrCreateDeviceIdentity(); const identityPath = path.join(stateDir, "identity", "device.json"); const raw = JSON.parse(await fs.readFile(identityPath, "utf8")) as { deviceId?: string };
expect(raw.deviceId).toBe(identity.deviceId);
});
});
it("reuses the stored identity on subsequent loads", async () => {
await withStateDirEnv("openclaw-identity-state-", async ({ stateDir }) => { const first = loadOrCreateDeviceIdentity(); const second = loadOrCreateDeviceIdentity(); const identityPath = path.join(stateDir, "identity", "device.json"); const raw = JSON.parse(await fs.readFile(identityPath, "utf8")) as {
deviceId?: string;
publicKeyPem?: string;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.