mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:51:22 +00:00
perf(test): speed up memory suites
This commit is contained in:
@@ -1009,12 +1009,16 @@ describe("QmdMemoryManager", () => {
|
||||
});
|
||||
|
||||
async function waitForCondition(check: () => boolean, timeoutMs: number): Promise<void> {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
while (Date.now() < deadline) {
|
||||
// Tests only need to yield the event loop a few times; real-time sleeps slow the suite down.
|
||||
const maxTicks = Math.max(10, Math.min(5000, timeoutMs * 5));
|
||||
for (let tick = 0; tick < maxTicks; tick += 1) {
|
||||
if (check()) {
|
||||
return;
|
||||
}
|
||||
await new Promise<void>((resolve) => setImmediate(resolve));
|
||||
}
|
||||
if (check()) {
|
||||
return;
|
||||
}
|
||||
throw new Error("condition was not met in time");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user