lint
This commit is contained in:
977 files changed
+198426
-158324
No files matched your search
@@ -6,33 +6,39 @@ import { RejectDoubtBuddyReq } from '../../../src/oidb-services/friend/reject-do
|
||||
import { env, v, s, m } from '../_pb-oracle';
|
||||
|
||||
function makeSender() {
|
||||
const respEnv: OidbBase<OidbEmpty> = { command: 0xD69, subCommand: 0, body: {} };
|
||||
const r: SendPacketResult = {
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '',
|
||||
responseData: Buffer.from(protobuf_encode<OidbBase<OidbEmpty>>(respEnv)),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
const respEnv: OidbBase<OidbEmpty> = { command: 0xd69, subCommand: 0, body: {} };
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.from(protobuf_encode<OidbBase<OidbEmpty>>(respEnv)),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('RejectDoubtBuddyReq namespace', () => {
|
||||
it('declares command 0xD69 sub 0, uin form', () => {
|
||||
expect(RejectDoubtBuddyReq.command).toBe(0xD69);
|
||||
expect(RejectDoubtBuddyReq.subCommand).toBe(0);
|
||||
expect(RejectDoubtBuddyReq.uinForm).toBe(true);
|
||||
});
|
||||
it('declares command 0xD69 sub 0, uin form', () => {
|
||||
expect(RejectDoubtBuddyReq.command).toBe(0xd69);
|
||||
expect(RejectDoubtBuddyReq.subCommand).toBe(0);
|
||||
expect(RejectDoubtBuddyReq.uinForm).toBe(true);
|
||||
});
|
||||
|
||||
it('serializes {1: const 3 (op discriminator), 3: {1: uid}}', () => {
|
||||
expect(RejectDoubtBuddyReq.serialize({} as any, { uid: 'u_x' })).toEqual({ field1: 3, inner: { uid: 'u_x' } });
|
||||
});
|
||||
it('serializes {1: const 3 (op discriminator), 3: {1: uid}}', () => {
|
||||
expect(RejectDoubtBuddyReq.serialize({} as any, { uid: 'u_x' })).toEqual({
|
||||
field1: 3,
|
||||
inner: { uid: 'u_x' },
|
||||
});
|
||||
});
|
||||
|
||||
it('byte-oracle: routes to 0xd69_0 and locks req tags {1:const3, 3:{1:uid}}', async () => {
|
||||
const sender = makeSender();
|
||||
await RejectDoubtBuddyReq.invoke(sender, { uid: 'u_abc' });
|
||||
it('byte-oracle: routes to 0xd69_0 and locks req tags {1:const3, 3:{1:uid}}', async () => {
|
||||
const sender = makeSender();
|
||||
await RejectDoubtBuddyReq.invoke(sender, { uid: 'u_abc' });
|
||||
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0xd69_0');
|
||||
const inner = [...s(1, 'u_abc')];
|
||||
const body = [...v(1, 3), ...m(3, inner)];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xD69, 0, body, true));
|
||||
});
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0xd69_0');
|
||||
const inner = [...s(1, 'u_abc')];
|
||||
const body = [...v(1, 3), ...m(3, inner)];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xd69, 0, body, true));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user