mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:30:44 +00:00
perf: reduce persistent dedupe test disk work
This commit is contained in:
@@ -70,16 +70,12 @@ describe("createPersistentDedupe", () => {
|
||||
const first = createDedupe(root);
|
||||
expect(await first.checkAndRecord("m1", { namespace: "a" })).toBe(true);
|
||||
expect(await first.checkAndRecord("m1", { namespace: "a" })).toBe(false);
|
||||
expect(await first.checkAndRecord("m2", { namespace: "a" })).toBe(true);
|
||||
|
||||
const second = createDedupe(root);
|
||||
expect(await second.hasRecent("m1", { namespace: "a" })).toBe(true);
|
||||
expect(await second.hasRecent("missing", { namespace: "a" })).toBe(false);
|
||||
expect(await second.warmup("a")).toBe(2);
|
||||
expect(await second.warmup("a")).toBe(1);
|
||||
expect(await second.checkAndRecord("m1", { namespace: "a" })).toBe(false);
|
||||
expect(await second.checkAndRecord("m2", { namespace: "a" })).toBe(false);
|
||||
expect(await second.checkAndRecord("m3", { namespace: "a" })).toBe(true);
|
||||
expect(await second.checkAndRecord("m1", { namespace: "b" })).toBe(true);
|
||||
expect(await second.checkAndRecord("m2", { namespace: "a" })).toBe(true);
|
||||
|
||||
const raceDedupe = createDedupe(root, { ttlMs: 10_000 });
|
||||
const [raceFirst, raceSecond] = await Promise.all([
|
||||
@@ -107,10 +103,11 @@ describe("createPersistentDedupe", () => {
|
||||
const emptyReader = createDedupe(root, { ttlMs: 10_000 });
|
||||
expect(await emptyReader.warmup("nonexistent")).toBe(0);
|
||||
|
||||
const writer = createDedupe(root, { ttlMs: 1000 });
|
||||
const oldNow = Date.now() - 2000;
|
||||
expect(await writer.checkAndRecord("old-msg", { namespace: "acct", now: oldNow })).toBe(true);
|
||||
expect(await writer.checkAndRecord("new-msg", { namespace: "acct" })).toBe(true);
|
||||
await fs.writeFile(
|
||||
path.join(root, "acct.json"),
|
||||
JSON.stringify({ "old-msg": oldNow, "new-msg": Date.now() }),
|
||||
);
|
||||
|
||||
const reader = createDedupe(root, { ttlMs: 1000 });
|
||||
expect(await reader.warmup("acct")).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user