diff --git a/src/config/io.audit.test.ts b/src/config/io.audit.test.ts index 3f6312afb69..b0322e86d27 100644 --- a/src/config/io.audit.test.ts +++ b/src/config/io.audit.test.ts @@ -10,32 +10,36 @@ import { resolveConfigAuditLogPath, } from "./io.audit.js"; +function createAuditRecordBase(configPath: string) { + return createConfigWriteAuditRecordBase({ + configPath, + env: {} as NodeJS.ProcessEnv, + existsBefore: true, + previousHash: "prev-hash", + nextHash: "next-hash", + previousBytes: 12, + nextBytes: 24, + previousMetadata: { + dev: "10", + ino: "11", + mode: 0o600, + nlink: 1, + uid: 501, + gid: 20, + }, + changedPathCount: 1, + hasMetaBefore: true, + hasMetaAfter: true, + gatewayModeBefore: "local", + gatewayModeAfter: "local", + suspicious: [], + now: "2026-04-07T08:00:00.000Z", + }); +} + function createRenameAuditRecord(home: string) { return finalizeConfigWriteAuditRecord({ - base: createConfigWriteAuditRecordBase({ - configPath: path.join(home, ".openclaw", "openclaw.json"), - env: {} as NodeJS.ProcessEnv, - existsBefore: true, - previousHash: "prev-hash", - nextHash: "next-hash", - previousBytes: 12, - nextBytes: 24, - previousMetadata: { - dev: "10", - ino: "11", - mode: 0o600, - nlink: 1, - uid: 501, - gid: 20, - }, - changedPathCount: 1, - hasMetaBefore: true, - hasMetaAfter: true, - gatewayModeBefore: "local", - gatewayModeAfter: "local", - suspicious: [], - now: "2026-04-07T08:00:00.000Z", - }), + base: createAuditRecordBase(path.join(home, ".openclaw", "openclaw.json")), result: "rename", nextMetadata: { dev: "12", @@ -155,30 +159,7 @@ describe("config io audit helpers", () => { }); it("drops next-file metadata and preserves error details for failed writes", () => { - const base = createConfigWriteAuditRecordBase({ - configPath: "/tmp/openclaw.json", - env: {} as NodeJS.ProcessEnv, - existsBefore: true, - previousHash: "prev-hash", - nextHash: "next-hash", - previousBytes: 12, - nextBytes: 24, - previousMetadata: { - dev: "10", - ino: "11", - mode: 0o600, - nlink: 1, - uid: 501, - gid: 20, - }, - changedPathCount: 1, - hasMetaBefore: true, - hasMetaAfter: true, - gatewayModeBefore: "local", - gatewayModeAfter: "local", - suspicious: [], - now: "2026-04-07T08:00:00.000Z", - }); + const base = createAuditRecordBase("/tmp/openclaw.json"); const err = Object.assign(new Error("disk full"), { code: "ENOSPC" }); const record = finalizeConfigWriteAuditRecord({ base,