SnowLuma v2.4.2 source snapshot
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
This commit is contained in:
commit
fa9c73363d
1367 files changed
+355735
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbDeleteFriend } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { DeleteFriend } from '../../../src/oidb-services/friend/delete-friend';
|
||||
import { env, m, s, v } from '../_pb-oracle';
|
||||
|
||||
function makeDeps() {
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.alloc(0),
|
||||
};
|
||||
return {
|
||||
sendRawPacket: vi.fn(async () => r),
|
||||
resolveUserUid: vi.fn(async () => 'resolved-uid'),
|
||||
};
|
||||
}
|
||||
|
||||
describe('DeleteFriend namespace', () => {
|
||||
it('declares 0x126B_0', () => {
|
||||
expect(DeleteFriend.command).toBe(0x126b);
|
||||
expect(DeleteFriend.subCommand).toBe(0);
|
||||
});
|
||||
|
||||
describe('invoke', () => {
|
||||
it('routes to OidbSvcTrpcTcp.0x126b_0', async () => {
|
||||
const deps = makeDeps();
|
||||
await DeleteFriend.invoke(deps, { userId: 10001 });
|
||||
expect(deps.sendRawPacket.mock.calls[0]![0]).toBe('OidbSvcTrpcTcp.0x126b_0');
|
||||
});
|
||||
|
||||
it('resolves the target uid before encoding', async () => {
|
||||
const deps = makeDeps();
|
||||
await DeleteFriend.invoke(deps, { userId: 10001 });
|
||||
expect(deps.resolveUserUid).toHaveBeenCalledWith(10001);
|
||||
});
|
||||
|
||||
it('packages the nested envelope with verbatim magic constants', async () => {
|
||||
const deps = makeDeps();
|
||||
await DeleteFriend.invoke(deps, { userId: 10001, block: true });
|
||||
const [, bytes] = deps.sendRawPacket.mock.calls[0]!;
|
||||
const env = protobuf_decode<OidbBase<OidbDeleteFriend>>(bytes);
|
||||
expect(env.body?.field1).toMatchObject({
|
||||
targetUid: 'resolved-uid',
|
||||
block: true,
|
||||
field2: {
|
||||
field1: 130,
|
||||
field2: 109,
|
||||
field3: { field1: 8, field2: 8, field3: 50 },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('matches the current QQ wire for a non-blocking delete', async () => {
|
||||
const deps = makeDeps();
|
||||
await DeleteFriend.invoke(deps, { userId: 10001 });
|
||||
const [wireName, bytes] = deps.sendRawPacket.mock.calls[0]!;
|
||||
const discriminator = [
|
||||
...v(1, 130),
|
||||
...v(2, 109),
|
||||
...m(3, [...v(1, 8), ...v(2, 8), ...v(3, 50)]),
|
||||
];
|
||||
const body = m(1, [
|
||||
...s(1, 'resolved-uid'),
|
||||
...m(2, discriminator),
|
||||
// Current QQ explicitly emits both booleans.
|
||||
...v(3, 0),
|
||||
...v(4, 1),
|
||||
]);
|
||||
expect({
|
||||
wireName,
|
||||
hex: Buffer.from(bytes).toString('hex'),
|
||||
}).toEqual({
|
||||
wireName: 'OidbSvcTrpcTcp.0x126b_0',
|
||||
hex: env(0x126b, 0, body, false),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user