@@ -2,7 +2,11 @@ import fs from "node:fs";
|
2 | 2 | import os from "node:os"; |
3 | 3 | import path from "node:path"; |
4 | 4 | import { afterEach, describe, expect, it, vi } from "vitest"; |
5 | | -import { readLogTail, waitForLog } from "../../scripts/e2e/telegram-user-crabbox-proof.ts"; |
| 5 | +import { |
| 6 | +readLogTail, |
| 7 | +readTelegramUserProofLogTailBytes, |
| 8 | +waitForLog, |
| 9 | +} from "../../scripts/e2e/telegram-user-crabbox-proof.ts"; |
6 | 10 | |
7 | 11 | const tempDirs: string[] = []; |
8 | 12 | |
@@ -20,6 +24,24 @@ afterEach(() => {
|
20 | 24 | }); |
21 | 25 | |
22 | 26 | describe("telegram user Crabbox proof log polling", () => { |
| 27 | +it("rejects loose numeric log tail limits instead of parsing prefixes", () => { |
| 28 | +expect(() => |
| 29 | +readTelegramUserProofLogTailBytes({ |
| 30 | +OPENCLAW_TELEGRAM_USER_PROOF_LOG_TAIL_BYTES: "1e3", |
| 31 | +}), |
| 32 | +).toThrow("invalid OPENCLAW_TELEGRAM_USER_PROOF_LOG_TAIL_BYTES: 1e3"); |
| 33 | +expect(() => |
| 34 | +readTelegramUserProofLogTailBytes({ |
| 35 | +OPENCLAW_TELEGRAM_USER_PROOF_LOG_TAIL_BYTES: "1000bytes", |
| 36 | +}), |
| 37 | +).toThrow("invalid OPENCLAW_TELEGRAM_USER_PROOF_LOG_TAIL_BYTES: 1000bytes"); |
| 38 | +expect( |
| 39 | +readTelegramUserProofLogTailBytes({ |
| 40 | +OPENCLAW_TELEGRAM_USER_PROOF_LOG_TAIL_BYTES: "4096", |
| 41 | +}), |
| 42 | +).toBe(4096); |
| 43 | +}); |
| 44 | + |
23 | 45 | it("reads only the requested log tail", () => { |
24 | 46 | const logPath = path.join(makeTempDir(), "gateway.log"); |
25 | 47 | fs.writeFileSync(logPath, `${"old\n".repeat(2000)}ready\n`, "utf8"); |
|