From ecea72df408b70770002b3ba1ac5fb2d37b04f0d Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Fri, 26 Jun 2026 17:09:18 +0800 Subject: [PATCH] test(onebot): expect forced full video upload retry on stale fast-path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NTV2 fast-upload video test still asserted a single sendRawPacket call, but #145 (forceFullOnFastPath) re-issues the OIDB request with fast-upload disabled when a flagged main file carrying real bytes is fast-pathed by the server. The stale assertion was never caught because the dev push workflow doesn't run the suite — only the PR gate (ci.yml) does, so it first surfaced on #149. Assert two packets go out and that the second round drops tryFastUploadCompleted, locking #145's behavior at the onebot layer. --- packages/onebot/tests/message-parser.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/onebot/tests/message-parser.test.ts b/packages/onebot/tests/message-parser.test.ts index cbd80e1f..652f89e1 100644 --- a/packages/onebot/tests/message-parser.test.ts +++ b/packages/onebot/tests/message-parser.test.ts @@ -8,7 +8,7 @@ import { buildSendElems } from '@snowluma/protocol/element-builder'; import type { MentionExtraSend } from '@snowluma/proto-defs/action'; import type { MarketFacePbReserve } from '@snowluma/proto-defs/element'; import type { OidbBase } from '@snowluma/proto-defs/oidb'; -import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway'; +import type { NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway'; describe('parseMessage', () => { describe('plain text', () => { @@ -275,8 +275,16 @@ describe('parseMessage', () => { thumbUrl: 'base64://iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=', }], { bridge, groupId: 123456 }); - expect(bridge.sendRawPacket).toHaveBeenCalledTimes(1); - expect(bridge.sendRawPacket).toHaveBeenCalledWith('OidbSvcTrpcTcp.0x11ea_100', expect.any(Uint8Array)); + // The video main file carries real bytes but the server fast-paths it + // (fileExist:true, no uKey) — #145's forceFullOnFastPath re-issues the + // OIDB request with fast-upload disabled, so two packets go out. + expect(bridge.sendRawPacket).toHaveBeenCalledTimes(2); + expect(bridge.sendRawPacket).toHaveBeenNthCalledWith(1, 'OidbSvcTrpcTcp.0x11ea_100', expect.any(Uint8Array)); + expect(bridge.sendRawPacket).toHaveBeenNthCalledWith(2, 'OidbSvcTrpcTcp.0x11ea_100', expect.any(Uint8Array)); + const firstReq = protobuf_decode>(bridge.sendRawPacket.mock.calls[0]![1] as Uint8Array); + const secondReq = protobuf_decode>(bridge.sendRawPacket.mock.calls[1]![1] as Uint8Array); + expect(firstReq.body.upload.tryFastUploadCompleted).toBe(true); + expect(secondReq.body.upload.tryFastUploadCompleted ?? false).toBe(false); expect(protoElems).toHaveLength(1); expect(protoElems[0].commonElem?.serviceType).toBe(48); expect(protoElems[0].commonElem?.businessType).toBe(21);