Remove bridge proto schemas and parity test

Delete proto schema modules under packages/core/src/bridge/proto (action.ts, element.ts, highway.ts, longmsg.ts, message.ts, notify.ts, oidb-action.ts, oidb.ts) and the related test packages/core/tests/proton-parity.test.ts. These files contained protobuf schema definitions for the bridge layer; remove them as part of a cleanup/refactor. Update any imports or references to these modules to their new locations or replacements.
This commit is contained in:
手瓜一十雪 committed 2026-05-20 18:23:03 +08:00
1 parent 02bab710b8
commit 5ea1c3a961
45 files changed
+1361 -4230

No files matched your search

@@ -1,8 +1,8 @@
import { describe, expect, it, vi } from 'vitest';
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { SendPacketResult } from '../src/protocol/packet-sender';
import { protoDecode, protoEncode } from '../src/protobuf/decode';
import { SendMessageRequestSchema, SendMessageResponseSchema } from '../src/bridge/proto/action';
import { FileExtraSchema } from '../src/bridge/proto/message';
import type { SendMessageRequest, SendMessageResponse } from '../src/bridge/proto/proton/action';
import type { FileExtra } from '../src/bridge/proto/proton/message';
vi.mock('../src/bridge/element-builder', () => ({
buildSendElems: vi.fn(async () => [{ text: { str: 'stub media elem' } }]),
@@ -29,11 +29,12 @@ describe('Bridge private media routing', () => {
gotResponse: true,
errorCode: 0,
errorMessage: '',
responseData: Buffer.from(protoEncode({
responseData: Buffer.from(protobuf_encode<SendMessageResponse>({
result: 0,
errMsg: '',
privateSequence: 88,
timestamp1: 1710000000,
}, SendMessageResponseSchema)),
})),
};
}
}
@@ -42,7 +43,7 @@ describe('Bridge private media routing', () => {
await bridge.sendPrivateMessage(12345, [{ type: 'video', url: 'file:///tmp/clip.mp4' } as any]);
expect(bridge.capturedBody).toBeInstanceOf(Uint8Array);
const request = protoDecode(bridge.capturedBody as Uint8Array, SendMessageRequestSchema);
const request = protobuf_decode<SendMessageRequest>(bridge.capturedBody as Uint8Array);
expect(request?.routingHead?.c2c).toMatchObject({
uin: 12345,
uid: 'u_peer_12345',
@@ -67,9 +68,9 @@ describe('Bridge private media routing', () => {
this.capturedBody = body;
return {
success: true, gotResponse: true, errorCode: 0, errorMessage: '',
responseData: Buffer.from(protoEncode({
result: 0, privateSequence: 88, timestamp1: 1710000000,
}, SendMessageResponseSchema)),
responseData: Buffer.from(protobuf_encode<SendMessageResponse>({
result: 0, errMsg: '', privateSequence: 88, timestamp1: 1710000000,
})),
};
}
}
@@ -84,27 +85,24 @@ describe('Bridge private media routing', () => {
fileHash: 'hash-xyz',
});
const request = protoDecode(bridge.capturedBody as Uint8Array, SendMessageRequestSchema);
const request = protobuf_decode<SendMessageRequest>(bridge.capturedBody as Uint8Array);
// Routing: must be trans0x211 with ccCmd=4 + uid, no c2c slot.
expect(request?.routingHead?.trans0x211).toMatchObject({
ccCmd: 4,
uid: 'u_peer_xyz',
});
expect(request?.routingHead?.c2c).toBeUndefined();
expect(request?.routingHead?.c2c ?? undefined).toBeUndefined();
// Body: msgContent carries the FileExtra; richText is absent (no
// elems, no notOnlineFile slot — both lived on the wrong place).
expect(request?.messageBody?.msgContent).toBeInstanceOf(Uint8Array);
expect(request?.messageBody?.richText).toBeUndefined();
expect(request?.messageBody?.richText ?? undefined).toBeUndefined();
// Decode the msgContent and verify the NotOnlineFile fields land
// at the correct tags (Lagrange's NotOnlineFile schema, not the
// dead FileExtraInfo one).
const fileExtra = protoDecode(
request!.messageBody!.msgContent as Uint8Array,
FileExtraSchema,
);
const fileExtra = protobuf_decode<FileExtra>(request!.messageBody!.msgContent as Uint8Array);
expect(fileExtra?.file).toMatchObject({
fileUuid: 'uuid-abc-123',
fileName: 'doc.txt',