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:
1 parent
02bab710b8
commit
5ea1c3a961
45 files changed
+1361
-4230
No files matched your search
@@ -3,9 +3,11 @@ import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '../../src/bridge/proto/proton/oidb';
|
||||
import type {
|
||||
OidbStrangerStatusResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/base';
|
||||
import type {
|
||||
OidbAiVoiceListResp,
|
||||
OidbAiVoiceResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-action';
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/media';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// that the plugin substitutes at the call site with the inlined codec, so
|
||||
|
||||
@@ -44,13 +44,13 @@ vi.mock('../../src/bridge/element-builder', () => ({
|
||||
buildSendElems: buildSendElemsMock,
|
||||
}));
|
||||
|
||||
import { protoEncode } from '../../src/protobuf/decode';
|
||||
import { SendLongMsgRespSchema } from '../../src/bridge/proto/longmsg';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { SendLongMsgResp } from '../../src/bridge/proto/proton/longmsg';
|
||||
import * as forward from '../../src/bridge/actions/forward';
|
||||
import { mockBridge } from './_helpers';
|
||||
|
||||
function uploadResponseWithResId(resId: string) {
|
||||
const encoded = protoEncode({ result: { resId } }, SendLongMsgRespSchema);
|
||||
const encoded = protobuf_encode<SendLongMsgResp>({ result: { resId } });
|
||||
return {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
|
||||
@@ -14,13 +14,13 @@ vi.mock('../../src/bridge/element-builder', () => ({
|
||||
buildSendElems: vi.fn(async () => []),
|
||||
}));
|
||||
|
||||
import { protoEncode } from '../../src/protobuf/decode';
|
||||
import { SendLongMsgRespSchema } from '../../src/bridge/proto/longmsg';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { SendLongMsgResp } from '../../src/bridge/proto/proton/longmsg';
|
||||
import * as forward from '../../src/bridge/actions/forward';
|
||||
import { mockBridge } from './_helpers';
|
||||
|
||||
function uploadResponseWithResId(resId: string) {
|
||||
const encoded = protoEncode({ result: { resId } }, SendLongMsgRespSchema);
|
||||
const encoded = protobuf_encode<SendLongMsgResp>({ result: { resId } });
|
||||
return {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
|
||||
@@ -15,8 +15,6 @@ describe('actions/friend', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.runOidb).mockClear();
|
||||
vi.mocked(oidb.makeOidbEnvelope).mockClear();
|
||||
vi.mocked(oidb.encodeOidbEnv).mockClear();
|
||||
vi.mocked(oidb.decodeOidbEnv).mockClear();
|
||||
});
|
||||
|
||||
it('setFriendAddRequest: numeric input is treated as UIN and resolved', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '../../src/bridge/proto/proton/oidb';
|
||||
import type { Oidb0x8a7Resp } from '../../src/bridge/proto/proton/oidb-action';
|
||||
import type { Oidb0x8a7Resp } from '../../src/bridge/proto/proton/oidb-actions/base';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// that the plugin substitutes at the call site with the inlined codec, so
|
||||
|
||||
@@ -5,10 +5,12 @@ import type {
|
||||
OidbGroupFileCountViewResp,
|
||||
OidbGroupFileResp,
|
||||
OidbGroupFileViewResp,
|
||||
OidbPrivateFileUploadResp,
|
||||
OidbGroupFileFolderResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/group-file';
|
||||
import type {
|
||||
OidbPrivateFileUploadResp,
|
||||
NTV2RichMediaResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-action';
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/media';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// (substituted at the call site with the inlined codec). Mocking them on
|
||||
|
||||
@@ -15,8 +15,6 @@ describe('actions/group-message', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.runOidb).mockClear();
|
||||
vi.mocked(oidb.makeOidbEnvelope).mockClear();
|
||||
vi.mocked(oidb.encodeOidbEnv).mockClear();
|
||||
vi.mocked(oidb.decodeOidbEnv).mockClear();
|
||||
});
|
||||
|
||||
it('recallGroupMessage sends to SsoGroupRecallMsg with the group sequence', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '../../src/bridge/proto/proton/oidb';
|
||||
import type { Oidb0x9083Resp } from '../../src/bridge/proto/proton/oidb-action';
|
||||
import type { Oidb0x9083Resp } from '../../src/bridge/proto/proton/oidb-actions/base';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// that the plugin substitutes at the call site for the inlined codec.
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { OidbBase } from '../../src/bridge/proto/proton/oidb';
|
||||
import type {
|
||||
Oidb0x990Resp,
|
||||
Oidb0x112eResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-action';
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/base';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// — the plugin substitutes them at the call site with the inlined codec,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '../../src/bridge/proto/proton/oidb';
|
||||
import type {
|
||||
GroupAvatarExtra,
|
||||
Oidb0x7edResp,
|
||||
Oidb0xe17Resp,
|
||||
} from '../../src/bridge/proto/proton/oidb-action';
|
||||
SetStatusReq,
|
||||
SetStatusResp,
|
||||
} from '../../src/bridge/proto/proton/oidb-actions/base';
|
||||
|
||||
// `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers
|
||||
// (substituted at the call site with the inlined codec). Mocking them on
|
||||
@@ -71,23 +74,19 @@ describe('actions/profile', () => {
|
||||
expect(serviceCmd).toBe('trpc.qq_new_tech.status_svc.StatusService.SetStatus');
|
||||
// Decode the wire bytes back through the same schema to assert
|
||||
// every field landed in the right place.
|
||||
const { protoDecode } = await import('../../src/protobuf/decode');
|
||||
const { SetStatusReqSchema } = await import('../../src/bridge/proto/oidb-action');
|
||||
const decoded = protoDecode(body as Uint8Array, SetStatusReqSchema);
|
||||
const decoded = protobuf_decode<SetStatusReq>(body as Uint8Array);
|
||||
expect(decoded).toMatchObject({
|
||||
status: 10,
|
||||
extStatus: 2000,
|
||||
batteryStatus: 0,
|
||||
customExt: { faceId: 1234, text: '摸鱼中', faceType: 2 },
|
||||
});
|
||||
expect(decoded.batteryStatus ?? 0).toBe(0);
|
||||
});
|
||||
|
||||
it('setDiyOnlineStatus surfaces server errors via the same path as setOnlineStatus', async () => {
|
||||
const bridge = mockBridge();
|
||||
// Build a response that decodes to errCode != 0.
|
||||
const { protoEncode } = await import('../../src/protobuf/decode');
|
||||
const { SetStatusRespSchema } = await import('../../src/bridge/proto/oidb-action');
|
||||
const respBuf = Buffer.from(protoEncode({ errCode: 1, errMsg: 'denied' }, SetStatusRespSchema));
|
||||
const respBuf = Buffer.from(protobuf_encode<SetStatusResp>({ errCode: 1, errMsg: 'denied' }));
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: respBuf,
|
||||
} as any);
|
||||
@@ -150,9 +149,7 @@ describe('actions/profile', () => {
|
||||
expect(cmdId).toBe(3000);
|
||||
// Decode the extra blob back through the schema and assert every
|
||||
// protocol-prescribed constant lands where it should.
|
||||
const { protoDecode } = await import('../../src/protobuf/decode');
|
||||
const { GroupAvatarExtraSchema } = await import('../../src/bridge/proto/oidb-action');
|
||||
const decoded = protoDecode(extend as Uint8Array, GroupAvatarExtraSchema);
|
||||
const decoded = protobuf_decode<GroupAvatarExtra>(extend as Uint8Array);
|
||||
expect(decoded).toEqual({
|
||||
type: 101,
|
||||
groupUin: 12345,
|
||||
|
||||
Reference in new issue
Block a user