test(telegram): keep live polling leases protected (#93378) (thanks @… · openclaw/openclaw@b3b8b28
obviyus
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -28,6 +28,31 @@ describe("Telegram polling lease", () => {
|
28 | 28 | first.release(); |
29 | 29 | }); |
30 | 30 | |
| 31 | +it("refuses an old active duplicate poller for the same bot token", async () => { |
| 32 | +vi.useFakeTimers(); |
| 33 | +try { |
| 34 | +const abort = new AbortController(); |
| 35 | +const first = await acquireTelegramPollingLease({ |
| 36 | +token: "123:abc", |
| 37 | +accountId: "default", |
| 38 | +abortSignal: abort.signal, |
| 39 | +}); |
| 40 | + |
| 41 | +await vi.advanceTimersByTimeAsync(6 * 60 * 1_000); |
| 42 | + |
| 43 | +await expect( |
| 44 | +acquireTelegramPollingLease({ |
| 45 | +token: "123:abc", |
| 46 | +accountId: "ops", |
| 47 | +}), |
| 48 | +).rejects.toThrow('refusing duplicate poller for account "ops"'); |
| 49 | + |
| 50 | +first.release(); |
| 51 | +} finally { |
| 52 | +vi.useRealTimers(); |
| 53 | +} |
| 54 | +}); |
| 55 | + |
31 | 56 | it("allows concurrent pollers for different bot tokens", async () => { |
32 | 57 | const first = await acquireTelegramPollingLease({ |
33 | 58 | token: "123:abc", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。