test(telegram): wait for polling watchdog deterministical...
steipete
·
2026-05-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -95,6 +95,8 @@ type WorkerMessageListener = (message: TelegramIngressWorkerMessage) => void;
|
95 | 95 | type AsyncVoidFn = () => Promise<void>; |
96 | 96 | type MockCallSource = { mock: { calls: Array<Array<unknown>> } }; |
97 | 97 | |
| 98 | +const POLLING_TEST_WATCHDOG_INTERVAL_MS = 30_000; |
| 99 | + |
98 | 100 | function mockObjectArg( |
99 | 101 | source: MockCallSource, |
100 | 102 | label: string, |
@@ -155,8 +157,10 @@ function makeBot() {
|
155 | 157 | |
156 | 158 | function installPollingStallWatchdogHarness(dateNowSequence: readonly number[] = [0, 0]) { |
157 | 159 | let watchdog: (() => void) | undefined; |
158 | | -const setIntervalSpy = vi.spyOn(globalThis, "setInterval").mockImplementation((fn) => { |
159 | | -watchdog = fn as () => void; |
| 160 | +const setIntervalSpy = vi.spyOn(globalThis, "setInterval").mockImplementation((fn, delay) => { |
| 161 | +if (delay === POLLING_TEST_WATCHDOG_INTERVAL_MS) { |
| 162 | +watchdog = fn as () => void; |
| 163 | +} |
160 | 164 | return 1 as unknown as ReturnType<typeof setInterval>; |
161 | 165 | }); |
162 | 166 | const clearIntervalSpy = vi.spyOn(globalThis, "clearInterval").mockImplementation(() => {}); |
@@ -173,7 +177,7 @@ function installPollingStallWatchdogHarness(dateNowSequence: readonly number[] =
|
173 | 177 | |
174 | 178 | return { |
175 | 179 | async waitForWatchdog() { |
176 | | -for (let attempt = 0; attempt < 20; attempt += 1) { |
| 180 | +for (let attempt = 0; attempt < 200; attempt += 1) { |
177 | 181 | if (watchdog) { |
178 | 182 | break; |
179 | 183 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。