test: simplify role allowlist node counts · openclaw/openclaw@3d5002f
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -40,6 +40,16 @@ const FAST_WAIT_OPTS = { timeout: 1_000, interval: 2 } as const;
|
40 | 40 | let ws: WebSocket; |
41 | 41 | let port: number; |
42 | 42 | |
| 43 | +function countConnectedNodes(nodes: readonly { connected?: boolean }[] | undefined): number { |
| 44 | +let count = 0; |
| 45 | +for (const node of nodes ?? []) { |
| 46 | +if (node.connected) { |
| 47 | +count++; |
| 48 | +} |
| 49 | +} |
| 50 | +return count; |
| 51 | +} |
| 52 | + |
43 | 53 | function installCanvasNodePolicyForTest() { |
44 | 54 | const registry = getActiveRuntimePluginRegistry(); |
45 | 55 | if (!registry) { |
@@ -326,8 +336,7 @@ describe("gateway node command allowlist", () => {
|
326 | 336 | const listRes = await rpcReq<{ |
327 | 337 | nodes?: Array<{ nodeId: string; connected?: boolean }>; |
328 | 338 | }>(ws, "node.list", {}); |
329 | | -const nodes = listRes.payload?.nodes ?? []; |
330 | | -return nodes.filter((node) => node.connected).length; |
| 339 | +return countConnectedNodes(listRes.payload?.nodes); |
331 | 340 | }, FAST_WAIT_OPTS) |
332 | 341 | .toBe(count); |
333 | 342 | }; |
@@ -554,7 +563,7 @@ describe("gateway node command allowlist", () => {
|
554 | 563 | "node.list", |
555 | 564 | {}, |
556 | 565 | ); |
557 | | -return (listRes.payload?.nodes ?? []).filter((node) => node.connected).length; |
| 566 | +return countConnectedNodes(listRes.payload?.nodes); |
558 | 567 | }, FAST_WAIT_OPTS) |
559 | 568 | .toBe(0); |
560 | 569 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。