fix(test): avoid huge chat attachment fixture · openclaw/openclaw@5fcab50
vincentkoc
·
2026-06-18
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -59,6 +59,13 @@ function pdfAttachment(overrides: Partial<ChatAttachment> = {}): ChatAttachment
|
59 | 59 | }; |
60 | 60 | } |
61 | 61 | |
| 62 | +function oversizedPngBase64(): string { |
| 63 | +const pngHeader = PNG_1x1.slice(0, 64); |
| 64 | +let base64Length = Math.ceil(((MAX_IMAGE_BYTES + 1) * 4) / 3); |
| 65 | +base64Length += (4 - (base64Length % 4)) % 4; |
| 66 | +return `${pngHeader}${"A".repeat(base64Length - pngHeader.length)}`; |
| 67 | +} |
| 68 | + |
62 | 69 | async function parseWithWarnings( |
63 | 70 | message: string, |
64 | 71 | attachments: ChatAttachment[], |
@@ -248,7 +255,7 @@ describe("parseMessageWithAttachments", () => {
|
248 | 255 | }); |
249 | 256 | |
250 | 257 | it("rejects oversized images before offload", async () => { |
251 | | -const big = Buffer.alloc(MAX_IMAGE_BYTES + 1, 1).toString("base64"); |
| 258 | +const big = oversizedPngBase64(); |
252 | 259 | |
253 | 260 | await expect( |
254 | 261 | parseMessageWithAttachments( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。