@mtcute/test 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/client.d.ts +8 -3
- package/cjs/client.js +20 -21
- package/cjs/client.js.map +1 -1
- package/cjs/client.test.d.ts +1 -0
- package/cjs/client.test.js +32 -0
- package/cjs/client.test.js.map +1 -0
- package/cjs/crypto.d.ts +6 -0
- package/cjs/crypto.js +162 -0
- package/cjs/crypto.js.map +1 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/storage-test.d.ts +24 -0
- package/cjs/storage-test.js +302 -0
- package/cjs/storage-test.js.map +1 -0
- package/cjs/storage.test.d.ts +1 -0
- package/cjs/storage.test.js +43 -0
- package/cjs/storage.test.js.map +1 -0
- package/cjs/stub.test.d.ts +1 -0
- package/cjs/stub.test.js +55 -0
- package/cjs/stub.test.js.map +1 -0
- package/cjs/transport.test.d.ts +1 -0
- package/cjs/transport.test.js +35 -0
- package/cjs/transport.test.js.map +1 -0
- package/cjs/utils.test.d.ts +1 -0
- package/cjs/utils.test.js +16 -0
- package/cjs/utils.test.js.map +1 -0
- package/esm/client.d.ts +8 -3
- package/esm/client.js +21 -22
- package/esm/client.js.map +1 -1
- package/esm/client.test.d.ts +1 -0
- package/esm/client.test.js +30 -0
- package/esm/client.test.js.map +1 -0
- package/esm/crypto.d.ts +6 -0
- package/esm/crypto.js +154 -0
- package/esm/crypto.js.map +1 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/storage-test.d.ts +24 -0
- package/esm/storage-test.js +294 -0
- package/esm/storage-test.js.map +1 -0
- package/esm/storage.test.d.ts +1 -0
- package/esm/storage.test.js +41 -0
- package/esm/storage.test.js.map +1 -0
- package/esm/stub.test.d.ts +1 -0
- package/esm/stub.test.js +50 -0
- package/esm/stub.test.js.map +1 -0
- package/esm/transport.test.d.ts +1 -0
- package/esm/transport.test.js +33 -0
- package/esm/transport.test.js.map +1 -0
- package/esm/utils.test.d.ts +1 -0
- package/esm/utils.test.js +14 -0
- package/esm/utils.test.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import Long from 'long';
|
|
2
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { defaultProductionDc, hexEncode, LogManager } from '@mtcute/core/utils.js';
|
|
4
|
+
import { __tlReaderMap } from '@mtcute/tl/binary/reader.js';
|
|
5
|
+
import { __tlWriterMap } from '@mtcute/tl/binary/writer.js';
|
|
6
|
+
import { createStub } from './stub.js';
|
|
7
|
+
export const stubPeerUser = {
|
|
8
|
+
id: 123123,
|
|
9
|
+
accessHash: Long.fromBits(123, 456),
|
|
10
|
+
type: 'user',
|
|
11
|
+
username: 'some_user',
|
|
12
|
+
phone: '78005553535',
|
|
13
|
+
full: createStub('user', { id: 123123 }),
|
|
14
|
+
};
|
|
15
|
+
const peerUserInput = {
|
|
16
|
+
_: 'inputPeerUser',
|
|
17
|
+
userId: 123123,
|
|
18
|
+
accessHash: Long.fromBits(123, 456),
|
|
19
|
+
};
|
|
20
|
+
const peerChannel = {
|
|
21
|
+
id: -1001183945448,
|
|
22
|
+
accessHash: Long.fromBits(666, 555),
|
|
23
|
+
type: 'channel',
|
|
24
|
+
username: 'some_channel',
|
|
25
|
+
full: createStub('channel', { id: 123123 }),
|
|
26
|
+
};
|
|
27
|
+
const peerChannelInput = {
|
|
28
|
+
_: 'inputPeerChannel',
|
|
29
|
+
channelId: 1183945448,
|
|
30
|
+
accessHash: Long.fromBits(666, 555),
|
|
31
|
+
};
|
|
32
|
+
function maybeHexEncode(x) {
|
|
33
|
+
if (x == null)
|
|
34
|
+
return null;
|
|
35
|
+
return hexEncode(x);
|
|
36
|
+
}
|
|
37
|
+
export function testStorage(s, params) {
|
|
38
|
+
beforeAll(async () => {
|
|
39
|
+
const logger = new LogManager();
|
|
40
|
+
logger.level = 0;
|
|
41
|
+
s.setup?.(logger, __tlReaderMap, __tlWriterMap);
|
|
42
|
+
await s.load?.();
|
|
43
|
+
});
|
|
44
|
+
afterAll(() => s.destroy?.());
|
|
45
|
+
beforeEach(() => s.reset(true));
|
|
46
|
+
describe('default dc', () => {
|
|
47
|
+
it('should store', async () => {
|
|
48
|
+
await s.setDefaultDcs(defaultProductionDc);
|
|
49
|
+
expect(await s.getDefaultDcs()).toEqual(defaultProductionDc);
|
|
50
|
+
});
|
|
51
|
+
it('should remove', async () => {
|
|
52
|
+
await s.setDefaultDcs(null);
|
|
53
|
+
expect(await s.getDefaultDcs()).toBeNull();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('auth keys', () => {
|
|
57
|
+
beforeAll(() => void vi.useFakeTimers());
|
|
58
|
+
afterAll(() => void vi.useRealTimers());
|
|
59
|
+
const key2 = new Uint8Array(256).fill(0x42);
|
|
60
|
+
const key3 = new Uint8Array(256).fill(0x43);
|
|
61
|
+
const key2i0 = new Uint8Array(256).fill(0x44);
|
|
62
|
+
const key2i1 = new Uint8Array(256).fill(0x45);
|
|
63
|
+
const key3i0 = new Uint8Array(256).fill(0x46);
|
|
64
|
+
const key3i1 = new Uint8Array(256).fill(0x47);
|
|
65
|
+
it('should store perm auth key', async () => {
|
|
66
|
+
await s.setAuthKeyFor(2, key2);
|
|
67
|
+
await s.setAuthKeyFor(3, key3);
|
|
68
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2));
|
|
69
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3));
|
|
70
|
+
});
|
|
71
|
+
it('should store temp auth keys', async () => {
|
|
72
|
+
const expire = Date.now() + 1000;
|
|
73
|
+
await s.setTempAuthKeyFor(2, 0, key2i0, expire);
|
|
74
|
+
await s.setTempAuthKeyFor(2, 1, key2i1, expire);
|
|
75
|
+
await s.setTempAuthKeyFor(3, 0, key3i0, expire);
|
|
76
|
+
await s.setTempAuthKeyFor(3, 1, key3i1, expire);
|
|
77
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(2, 0))).toEqual(hexEncode(key2i0));
|
|
78
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(2, 1))).toEqual(hexEncode(key2i1));
|
|
79
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3, 0))).toEqual(hexEncode(key3i0));
|
|
80
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3, 1))).toEqual(hexEncode(key3i1));
|
|
81
|
+
});
|
|
82
|
+
it('should expire temp auth keys', async () => {
|
|
83
|
+
const expire = Date.now() + 1000;
|
|
84
|
+
await s.setTempAuthKeyFor(2, 0, key2i0, expire);
|
|
85
|
+
await s.setTempAuthKeyFor(2, 1, key2i1, expire);
|
|
86
|
+
await s.setTempAuthKeyFor(3, 0, key3i0, expire);
|
|
87
|
+
await s.setTempAuthKeyFor(3, 1, key3i1, expire);
|
|
88
|
+
vi.advanceTimersByTime(10000);
|
|
89
|
+
expect(await s.getAuthKeyFor(2, 0)).toBeNull();
|
|
90
|
+
expect(await s.getAuthKeyFor(2, 1)).toBeNull();
|
|
91
|
+
expect(await s.getAuthKeyFor(3, 0)).toBeNull();
|
|
92
|
+
expect(await s.getAuthKeyFor(3, 1)).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
it('should remove auth keys', async () => {
|
|
95
|
+
const expire = Date.now() + 1000;
|
|
96
|
+
await s.setTempAuthKeyFor(2, 0, key2i0, expire);
|
|
97
|
+
await s.setTempAuthKeyFor(2, 1, key2i1, expire);
|
|
98
|
+
await s.setAuthKeyFor(2, key2);
|
|
99
|
+
await s.setAuthKeyFor(3, key3);
|
|
100
|
+
await s.setAuthKeyFor(2, null);
|
|
101
|
+
await s.setTempAuthKeyFor(2, 0, null, 0);
|
|
102
|
+
await s.setTempAuthKeyFor(2, 1, null, 0);
|
|
103
|
+
expect(await s.getAuthKeyFor(2)).toBeNull();
|
|
104
|
+
expect(await s.getAuthKeyFor(2, 0)).toBeNull();
|
|
105
|
+
expect(await s.getAuthKeyFor(2, 1)).toBeNull();
|
|
106
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3)); // should not be removed
|
|
107
|
+
});
|
|
108
|
+
it('should remove all auth keys with dropAuthKeysFor', async () => {
|
|
109
|
+
const expire = Date.now() + 1000;
|
|
110
|
+
await s.setTempAuthKeyFor(2, 0, key2i0, expire);
|
|
111
|
+
await s.setTempAuthKeyFor(2, 1, key2i1, expire);
|
|
112
|
+
await s.setAuthKeyFor(2, key2);
|
|
113
|
+
await s.setAuthKeyFor(3, key3);
|
|
114
|
+
await s.dropAuthKeysFor(2);
|
|
115
|
+
expect(await s.getAuthKeyFor(2)).toBeNull();
|
|
116
|
+
expect(await s.getAuthKeyFor(2, 0)).toBeNull();
|
|
117
|
+
expect(await s.getAuthKeyFor(2, 1)).toBeNull();
|
|
118
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3)); // should not be removed
|
|
119
|
+
});
|
|
120
|
+
it('should not reset auth keys on reset()', async () => {
|
|
121
|
+
await s.setAuthKeyFor(2, key2);
|
|
122
|
+
await s.setAuthKeyFor(3, key3);
|
|
123
|
+
s.reset();
|
|
124
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2));
|
|
125
|
+
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3));
|
|
126
|
+
});
|
|
127
|
+
it('should reset auth keys on reset(true)', async () => {
|
|
128
|
+
await s.setAuthKeyFor(2, key2);
|
|
129
|
+
await s.setAuthKeyFor(3, key3);
|
|
130
|
+
s.reset(true);
|
|
131
|
+
expect(await s.getAuthKeyFor(2)).toBeNull();
|
|
132
|
+
expect(await s.getAuthKeyFor(3)).toBeNull();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe('peers', () => {
|
|
136
|
+
it('should cache and return peers', async () => {
|
|
137
|
+
await s.updatePeers([stubPeerUser, peerChannel]);
|
|
138
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
139
|
+
expect(await s.getPeerById(stubPeerUser.id)).toEqual(peerUserInput);
|
|
140
|
+
expect(await s.getPeerById(peerChannel.id)).toEqual(peerChannelInput);
|
|
141
|
+
});
|
|
142
|
+
it('should cache and return peers by username', async () => {
|
|
143
|
+
await s.updatePeers([stubPeerUser, peerChannel]);
|
|
144
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
145
|
+
expect(await s.getPeerByUsername(stubPeerUser.username)).toEqual(peerUserInput);
|
|
146
|
+
expect(await s.getPeerByUsername(peerChannel.username)).toEqual(peerChannelInput);
|
|
147
|
+
});
|
|
148
|
+
it('should cache and return peers by phone', async () => {
|
|
149
|
+
await s.updatePeers([stubPeerUser]);
|
|
150
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
151
|
+
expect(await s.getPeerByPhone(stubPeerUser.phone)).toEqual(peerUserInput);
|
|
152
|
+
});
|
|
153
|
+
if (!params?.skipEntityOverwrite) {
|
|
154
|
+
it('should overwrite existing cached peers', async () => {
|
|
155
|
+
await s.updatePeers([stubPeerUser]);
|
|
156
|
+
await s.updatePeers([{ ...stubPeerUser, username: 'whatever' }]);
|
|
157
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
158
|
+
expect(await s.getPeerById(stubPeerUser.id)).toEqual(peerUserInput);
|
|
159
|
+
expect(await s.getPeerByUsername(stubPeerUser.username)).toBeNull();
|
|
160
|
+
expect(await s.getPeerByUsername('whatever')).toEqual(peerUserInput);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
it('should cache full peer info', async () => {
|
|
164
|
+
await s.updatePeers([stubPeerUser, peerChannel]);
|
|
165
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
166
|
+
expect(await s.getFullPeerById(stubPeerUser.id)).toEqual(stubPeerUser.full);
|
|
167
|
+
expect(await s.getFullPeerById(peerChannel.id)).toEqual(peerChannel.full);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('current user', () => {
|
|
171
|
+
const self = {
|
|
172
|
+
userId: 123123,
|
|
173
|
+
isBot: false,
|
|
174
|
+
};
|
|
175
|
+
it('should store and return self info', async () => {
|
|
176
|
+
await s.setSelf(self);
|
|
177
|
+
expect(await s.getSelf()).toEqual(self);
|
|
178
|
+
});
|
|
179
|
+
it('should remove self info', async () => {
|
|
180
|
+
await s.setSelf(self);
|
|
181
|
+
await s.setSelf(null);
|
|
182
|
+
expect(await s.getSelf()).toBeNull();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
describe('updates state', () => {
|
|
186
|
+
it('should store and return updates state', async () => {
|
|
187
|
+
await s.setUpdatesPts(1);
|
|
188
|
+
await s.setUpdatesQts(2);
|
|
189
|
+
await s.setUpdatesDate(3);
|
|
190
|
+
await s.setUpdatesSeq(4);
|
|
191
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
192
|
+
expect(await s.getUpdatesState()).toEqual([1, 2, 3, 4]);
|
|
193
|
+
});
|
|
194
|
+
it('should store and return channel pts', async () => {
|
|
195
|
+
await s.setManyChannelPts(new Map([
|
|
196
|
+
[1, 2],
|
|
197
|
+
[3, 4],
|
|
198
|
+
]));
|
|
199
|
+
await s.save?.(); // update-related methods are batched, so we need to save
|
|
200
|
+
expect(await s.getChannelPts(1)).toEqual(2);
|
|
201
|
+
expect(await s.getChannelPts(3)).toEqual(4);
|
|
202
|
+
expect(await s.getChannelPts(2)).toBeNull();
|
|
203
|
+
});
|
|
204
|
+
it('should be null after reset', async () => {
|
|
205
|
+
expect(await s.getUpdatesState()).toBeNull();
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
params?.customTests?.(s);
|
|
209
|
+
}
|
|
210
|
+
export function testStateStorage(s) {
|
|
211
|
+
beforeAll(async () => {
|
|
212
|
+
const logger = new LogManager();
|
|
213
|
+
logger.level = 0;
|
|
214
|
+
s.setup?.(logger, __tlReaderMap, __tlWriterMap);
|
|
215
|
+
await s.load?.();
|
|
216
|
+
});
|
|
217
|
+
afterAll(() => s.destroy?.());
|
|
218
|
+
beforeEach(() => s.reset());
|
|
219
|
+
describe('key-value state', () => {
|
|
220
|
+
beforeAll(() => void vi.useFakeTimers());
|
|
221
|
+
afterAll(() => void vi.useRealTimers());
|
|
222
|
+
it('should store and return state', async () => {
|
|
223
|
+
await s.setState('a', 'b');
|
|
224
|
+
await s.setState('c', 'd');
|
|
225
|
+
await s.setState('e', 'f');
|
|
226
|
+
expect(await s.getState('a')).toEqual('b');
|
|
227
|
+
expect(await s.getState('c')).toEqual('d');
|
|
228
|
+
expect(await s.getState('e')).toEqual('f');
|
|
229
|
+
});
|
|
230
|
+
it('should remove state', async () => {
|
|
231
|
+
await s.setState('a', 'b');
|
|
232
|
+
await s.setState('c', 'd');
|
|
233
|
+
await s.setState('e', 'f');
|
|
234
|
+
await s.deleteState('a');
|
|
235
|
+
await s.deleteState('c');
|
|
236
|
+
await s.deleteState('e');
|
|
237
|
+
expect(await s.getState('a')).toBeNull();
|
|
238
|
+
expect(await s.getState('c')).toBeNull();
|
|
239
|
+
expect(await s.getState('e')).toBeNull();
|
|
240
|
+
});
|
|
241
|
+
it('should expire state', async () => {
|
|
242
|
+
await s.setState('a', 'b', 1);
|
|
243
|
+
await s.setState('c', 'd', 1);
|
|
244
|
+
await s.setState('e', 'f', 1);
|
|
245
|
+
vi.advanceTimersByTime(10000);
|
|
246
|
+
expect(await s.getState('a')).toBeNull();
|
|
247
|
+
expect(await s.getState('c')).toBeNull();
|
|
248
|
+
expect(await s.getState('e')).toBeNull();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
describe('scenes', () => {
|
|
252
|
+
it('should store and return scenes', async () => {
|
|
253
|
+
await s.setCurrentScene('a', 'b');
|
|
254
|
+
await s.setCurrentScene('c', 'd');
|
|
255
|
+
await s.setCurrentScene('e', 'f');
|
|
256
|
+
expect(await s.getCurrentScene('a')).toEqual('b');
|
|
257
|
+
expect(await s.getCurrentScene('c')).toEqual('d');
|
|
258
|
+
expect(await s.getCurrentScene('e')).toEqual('f');
|
|
259
|
+
});
|
|
260
|
+
it('should remove scenes', async () => {
|
|
261
|
+
await s.setCurrentScene('a', 'b');
|
|
262
|
+
await s.setCurrentScene('c', 'd');
|
|
263
|
+
await s.setCurrentScene('e', 'f');
|
|
264
|
+
await s.deleteCurrentScene('a');
|
|
265
|
+
await s.deleteCurrentScene('c');
|
|
266
|
+
await s.deleteCurrentScene('e');
|
|
267
|
+
expect(await s.getCurrentScene('a')).toBeNull();
|
|
268
|
+
expect(await s.getCurrentScene('c')).toBeNull();
|
|
269
|
+
expect(await s.getCurrentScene('e')).toBeNull();
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('rate limit', () => {
|
|
273
|
+
beforeAll(() => void vi.useFakeTimers());
|
|
274
|
+
afterAll(() => void vi.useRealTimers());
|
|
275
|
+
const check = () => s.getRateLimit('test', 3, 1);
|
|
276
|
+
it('should implement basic rate limiting', async () => {
|
|
277
|
+
vi.setSystemTime(0);
|
|
278
|
+
expect(await check()).toEqual([3, 1000]);
|
|
279
|
+
expect(await check()).toEqual([2, 1000]);
|
|
280
|
+
expect(await check()).toEqual([1, 1000]);
|
|
281
|
+
expect(await check()).toEqual([0, 1000]);
|
|
282
|
+
vi.setSystemTime(1001);
|
|
283
|
+
expect(await check()).toEqual([3, 2001]);
|
|
284
|
+
});
|
|
285
|
+
it('should allow resetting rate limit', async () => {
|
|
286
|
+
vi.setSystemTime(0);
|
|
287
|
+
await check();
|
|
288
|
+
await check();
|
|
289
|
+
await s.resetRateLimit('test');
|
|
290
|
+
expect(await check()).toEqual([3, 1000]);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=storage-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-test.js","sourceRoot":"","sources":["../../src/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AAC,CAAA;YAEnB,MAAM,KAAK,EAAE,CAAA;YACb,MAAM,KAAK,EAAE,CAAA;YAEb,MAAM,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;YAC9B,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import Long from 'long'\nimport { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport { ITelegramStorage, MaybeAsync } from '@mtcute/core'\nimport { defaultProductionDc, hexEncode, Logger, LogManager, TlReaderMap, TlWriterMap } from '@mtcute/core/utils.js'\nimport { tl } from '@mtcute/tl'\nimport { __tlReaderMap } from '@mtcute/tl/binary/reader.js'\nimport { __tlWriterMap } from '@mtcute/tl/binary/writer.js'\n\nimport { createStub } from './stub.js'\n\nexport const stubPeerUser: ITelegramStorage.PeerInfo = {\n id: 123123,\n accessHash: Long.fromBits(123, 456),\n type: 'user',\n username: 'some_user',\n phone: '78005553535',\n full: createStub('user', { id: 123123 }),\n}\nconst peerUserInput: tl.TypeInputPeer = {\n _: 'inputPeerUser',\n userId: 123123,\n accessHash: Long.fromBits(123, 456),\n}\n\nconst peerChannel: ITelegramStorage.PeerInfo = {\n id: -1001183945448,\n accessHash: Long.fromBits(666, 555),\n type: 'channel',\n username: 'some_channel',\n full: createStub('channel', { id: 123123 }),\n}\n\nconst peerChannelInput: tl.TypeInputPeer = {\n _: 'inputPeerChannel',\n channelId: 1183945448,\n accessHash: Long.fromBits(666, 555),\n}\n\nfunction maybeHexEncode(x: Uint8Array | null): string | null {\n if (x == null) return null\n\n return hexEncode(x)\n}\n\nexport function testStorage<T extends ITelegramStorage>(\n s: T,\n params?: {\n skipEntityOverwrite?: boolean\n customTests?: (s: T) => void\n },\n): void {\n beforeAll(async () => {\n const logger = new LogManager()\n logger.level = 0\n s.setup?.(logger, __tlReaderMap, __tlWriterMap)\n\n await s.load?.()\n })\n\n afterAll(() => s.destroy?.())\n beforeEach(() => s.reset(true))\n\n describe('default dc', () => {\n it('should store', async () => {\n await s.setDefaultDcs(defaultProductionDc)\n expect(await s.getDefaultDcs()).toEqual(defaultProductionDc)\n })\n\n it('should remove', async () => {\n await s.setDefaultDcs(null)\n expect(await s.getDefaultDcs()).toBeNull()\n })\n })\n\n describe('auth keys', () => {\n beforeAll(() => void vi.useFakeTimers())\n afterAll(() => void vi.useRealTimers())\n\n const key2 = new Uint8Array(256).fill(0x42)\n const key3 = new Uint8Array(256).fill(0x43)\n\n const key2i0 = new Uint8Array(256).fill(0x44)\n const key2i1 = new Uint8Array(256).fill(0x45)\n const key3i0 = new Uint8Array(256).fill(0x46)\n const key3i1 = new Uint8Array(256).fill(0x47)\n\n it('should store perm auth key', async () => {\n await s.setAuthKeyFor(2, key2)\n await s.setAuthKeyFor(3, key3)\n\n expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2))\n expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3))\n })\n\n it('should store temp auth keys', async () => {\n const expire = Date.now() + 1000\n\n await s.setTempAuthKeyFor(2, 0, key2i0, expire)\n await s.setTempAuthKeyFor(2, 1, key2i1, expire)\n await s.setTempAuthKeyFor(3, 0, key3i0, expire)\n await s.setTempAuthKeyFor(3, 1, key3i1, expire)\n\n expect(maybeHexEncode(await s.getAuthKeyFor(2, 0))).toEqual(hexEncode(key2i0))\n expect(maybeHexEncode(await s.getAuthKeyFor(2, 1))).toEqual(hexEncode(key2i1))\n expect(maybeHexEncode(await s.getAuthKeyFor(3, 0))).toEqual(hexEncode(key3i0))\n expect(maybeHexEncode(await s.getAuthKeyFor(3, 1))).toEqual(hexEncode(key3i1))\n })\n\n it('should expire temp auth keys', async () => {\n const expire = Date.now() + 1000\n\n await s.setTempAuthKeyFor(2, 0, key2i0, expire)\n await s.setTempAuthKeyFor(2, 1, key2i1, expire)\n await s.setTempAuthKeyFor(3, 0, key3i0, expire)\n await s.setTempAuthKeyFor(3, 1, key3i1, expire)\n\n vi.advanceTimersByTime(10000)\n\n expect(await s.getAuthKeyFor(2, 0)).toBeNull()\n expect(await s.getAuthKeyFor(2, 1)).toBeNull()\n expect(await s.getAuthKeyFor(3, 0)).toBeNull()\n expect(await s.getAuthKeyFor(3, 1)).toBeNull()\n })\n\n it('should remove auth keys', async () => {\n const expire = Date.now() + 1000\n\n await s.setTempAuthKeyFor(2, 0, key2i0, expire)\n await s.setTempAuthKeyFor(2, 1, key2i1, expire)\n await s.setAuthKeyFor(2, key2)\n await s.setAuthKeyFor(3, key3)\n\n await s.setAuthKeyFor(2, null)\n await s.setTempAuthKeyFor(2, 0, null, 0)\n await s.setTempAuthKeyFor(2, 1, null, 0)\n\n expect(await s.getAuthKeyFor(2)).toBeNull()\n expect(await s.getAuthKeyFor(2, 0)).toBeNull()\n expect(await s.getAuthKeyFor(2, 1)).toBeNull()\n expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3)) // should not be removed\n })\n\n it('should remove all auth keys with dropAuthKeysFor', async () => {\n const expire = Date.now() + 1000\n\n await s.setTempAuthKeyFor(2, 0, key2i0, expire)\n await s.setTempAuthKeyFor(2, 1, key2i1, expire)\n await s.setAuthKeyFor(2, key2)\n await s.setAuthKeyFor(3, key3)\n\n await s.dropAuthKeysFor(2)\n\n expect(await s.getAuthKeyFor(2)).toBeNull()\n expect(await s.getAuthKeyFor(2, 0)).toBeNull()\n expect(await s.getAuthKeyFor(2, 1)).toBeNull()\n expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3)) // should not be removed\n })\n\n it('should not reset auth keys on reset()', async () => {\n await s.setAuthKeyFor(2, key2)\n await s.setAuthKeyFor(3, key3)\n s.reset()\n\n expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2))\n expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3))\n })\n\n it('should reset auth keys on reset(true)', async () => {\n await s.setAuthKeyFor(2, key2)\n await s.setAuthKeyFor(3, key3)\n s.reset(true)\n\n expect(await s.getAuthKeyFor(2)).toBeNull()\n expect(await s.getAuthKeyFor(3)).toBeNull()\n })\n })\n\n describe('peers', () => {\n it('should cache and return peers', async () => {\n await s.updatePeers([stubPeerUser, peerChannel])\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getPeerById(stubPeerUser.id)).toEqual(peerUserInput)\n expect(await s.getPeerById(peerChannel.id)).toEqual(peerChannelInput)\n })\n\n it('should cache and return peers by username', async () => {\n await s.updatePeers([stubPeerUser, peerChannel])\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getPeerByUsername(stubPeerUser.username!)).toEqual(peerUserInput)\n expect(await s.getPeerByUsername(peerChannel.username!)).toEqual(peerChannelInput)\n })\n\n it('should cache and return peers by phone', async () => {\n await s.updatePeers([stubPeerUser])\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getPeerByPhone(stubPeerUser.phone!)).toEqual(peerUserInput)\n })\n\n if (!params?.skipEntityOverwrite) {\n it('should overwrite existing cached peers', async () => {\n await s.updatePeers([stubPeerUser])\n await s.updatePeers([{ ...stubPeerUser, username: 'whatever' }])\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getPeerById(stubPeerUser.id)).toEqual(peerUserInput)\n expect(await s.getPeerByUsername(stubPeerUser.username!)).toBeNull()\n expect(await s.getPeerByUsername('whatever')).toEqual(peerUserInput)\n })\n }\n\n it('should cache full peer info', async () => {\n await s.updatePeers([stubPeerUser, peerChannel])\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getFullPeerById(stubPeerUser.id)).toEqual(stubPeerUser.full)\n expect(await s.getFullPeerById(peerChannel.id)).toEqual(peerChannel.full)\n })\n })\n\n describe('current user', () => {\n const self: ITelegramStorage.SelfInfo = {\n userId: 123123,\n isBot: false,\n }\n\n it('should store and return self info', async () => {\n await s.setSelf(self)\n expect(await s.getSelf()).toEqual(self)\n })\n\n it('should remove self info', async () => {\n await s.setSelf(self)\n await s.setSelf(null)\n expect(await s.getSelf()).toBeNull()\n })\n })\n\n describe('updates state', () => {\n it('should store and return updates state', async () => {\n await s.setUpdatesPts(1)\n await s.setUpdatesQts(2)\n await s.setUpdatesDate(3)\n await s.setUpdatesSeq(4)\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getUpdatesState()).toEqual([1, 2, 3, 4])\n })\n\n it('should store and return channel pts', async () => {\n await s.setManyChannelPts(\n new Map([\n [1, 2],\n [3, 4],\n ]),\n )\n await s.save?.() // update-related methods are batched, so we need to save\n\n expect(await s.getChannelPts(1)).toEqual(2)\n expect(await s.getChannelPts(3)).toEqual(4)\n expect(await s.getChannelPts(2)).toBeNull()\n })\n\n it('should be null after reset', async () => {\n expect(await s.getUpdatesState()).toBeNull()\n })\n })\n\n params?.customTests?.(s)\n}\n\ninterface IStateStorage {\n setup?(log: Logger, readerMap: TlReaderMap, writerMap: TlWriterMap): void\n\n load?(): MaybeAsync<void>\n\n save?(): MaybeAsync<void>\n\n destroy?(): MaybeAsync<void>\n\n reset(): MaybeAsync<void>\n\n getState(key: string): MaybeAsync<unknown>\n\n setState(key: string, state: unknown, ttl?: number): MaybeAsync<void>\n\n deleteState(key: string): MaybeAsync<void>\n\n getCurrentScene(key: string): MaybeAsync<string | null>\n\n setCurrentScene(key: string, scene: string, ttl?: number): MaybeAsync<void>\n\n deleteCurrentScene(key: string): MaybeAsync<void>\n\n getRateLimit(key: string, limit: number, window: number): MaybeAsync<[number, number]>\n\n resetRateLimit(key: string): MaybeAsync<void>\n}\n\nexport function testStateStorage(s: IStateStorage) {\n beforeAll(async () => {\n const logger = new LogManager()\n logger.level = 0\n s.setup?.(logger, __tlReaderMap, __tlWriterMap)\n\n await s.load?.()\n })\n\n afterAll(() => s.destroy?.())\n beforeEach(() => s.reset())\n\n describe('key-value state', () => {\n beforeAll(() => void vi.useFakeTimers())\n afterAll(() => void vi.useRealTimers())\n\n it('should store and return state', async () => {\n await s.setState('a', 'b')\n await s.setState('c', 'd')\n await s.setState('e', 'f')\n\n expect(await s.getState('a')).toEqual('b')\n expect(await s.getState('c')).toEqual('d')\n expect(await s.getState('e')).toEqual('f')\n })\n\n it('should remove state', async () => {\n await s.setState('a', 'b')\n await s.setState('c', 'd')\n await s.setState('e', 'f')\n\n await s.deleteState('a')\n await s.deleteState('c')\n await s.deleteState('e')\n\n expect(await s.getState('a')).toBeNull()\n expect(await s.getState('c')).toBeNull()\n expect(await s.getState('e')).toBeNull()\n })\n\n it('should expire state', async () => {\n await s.setState('a', 'b', 1)\n await s.setState('c', 'd', 1)\n await s.setState('e', 'f', 1)\n\n vi.advanceTimersByTime(10000)\n\n expect(await s.getState('a')).toBeNull()\n expect(await s.getState('c')).toBeNull()\n expect(await s.getState('e')).toBeNull()\n })\n })\n\n describe('scenes', () => {\n it('should store and return scenes', async () => {\n await s.setCurrentScene('a', 'b')\n await s.setCurrentScene('c', 'd')\n await s.setCurrentScene('e', 'f')\n\n expect(await s.getCurrentScene('a')).toEqual('b')\n expect(await s.getCurrentScene('c')).toEqual('d')\n expect(await s.getCurrentScene('e')).toEqual('f')\n })\n\n it('should remove scenes', async () => {\n await s.setCurrentScene('a', 'b')\n await s.setCurrentScene('c', 'd')\n await s.setCurrentScene('e', 'f')\n\n await s.deleteCurrentScene('a')\n await s.deleteCurrentScene('c')\n await s.deleteCurrentScene('e')\n\n expect(await s.getCurrentScene('a')).toBeNull()\n expect(await s.getCurrentScene('c')).toBeNull()\n expect(await s.getCurrentScene('e')).toBeNull()\n })\n })\n\n describe('rate limit', () => {\n beforeAll(() => void vi.useFakeTimers())\n afterAll(() => void vi.useRealTimers())\n\n const check = () => s.getRateLimit('test', 3, 1)\n\n it('should implement basic rate limiting', async () => {\n vi.setSystemTime(0)\n\n expect(await check()).toEqual([3, 1000])\n expect(await check()).toEqual([2, 1000])\n expect(await check()).toEqual([1, 1000])\n expect(await check()).toEqual([0, 1000])\n\n vi.setSystemTime(1001)\n\n expect(await check()).toEqual([3, 2001])\n })\n\n it('should allow resetting rate limit', async () => {\n vi.setSystemTime(0)\n\n await check()\n await check()\n\n await s.resetRateLimit('test')\n expect(await check()).toEqual([3, 1000])\n })\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { BaseTelegramClient } from '@mtcute/core';
|
|
3
|
+
import { StubMemoryTelegramStorage } from './storage.js';
|
|
4
|
+
import { createStub } from './stub.js';
|
|
5
|
+
import { StubTelegramTransport } from './transport.js';
|
|
6
|
+
describe('storage stub', () => {
|
|
7
|
+
it('should correctly intercept calls', async () => {
|
|
8
|
+
const log = [];
|
|
9
|
+
const client = new BaseTelegramClient({
|
|
10
|
+
apiId: 0,
|
|
11
|
+
apiHash: '',
|
|
12
|
+
logLevel: 0,
|
|
13
|
+
defaultDcs: {
|
|
14
|
+
main: createStub('dcOption', { ipAddress: '1.2.3.4', port: 1234 }),
|
|
15
|
+
media: createStub('dcOption', { ipAddress: '1.2.3.4', port: 5678 }),
|
|
16
|
+
},
|
|
17
|
+
transport: () => new StubTelegramTransport({
|
|
18
|
+
onMessage: (msg) => {
|
|
19
|
+
if (msg.slice(0, 8).reduce((a, b) => a + b, 0) === 0) {
|
|
20
|
+
// should not happen, since we're providing stub keys
|
|
21
|
+
log.push('unauthed_message');
|
|
22
|
+
}
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
client.close().catch(() => { });
|
|
25
|
+
}, 10);
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
storage: new StubMemoryTelegramStorage({
|
|
29
|
+
hasKeys: true,
|
|
30
|
+
onLoad: () => log.push('load'),
|
|
31
|
+
onSave: () => log.push('save'),
|
|
32
|
+
onDestroy: () => log.push('destroy'),
|
|
33
|
+
onReset: () => log.push('reset'),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
await client.connect();
|
|
37
|
+
await client.call({ _: 'help.getConfig' }).catch(() => { }); // ignore "client closed" error
|
|
38
|
+
expect(log).toEqual(['load', 'save', 'destroy']);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=storage.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.test.js","sourceRoot":"","sources":["../../src/storage.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,GAAG,GAAa,EAAE,CAAA;QAExB,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC;YAClC,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE;gBACR,IAAI,EAAE,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAClE,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aACtE;YACD,SAAS,EAAE,GAAG,EAAE,CACZ,IAAI,qBAAqB,CAAC;gBACtB,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;oBACf,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;wBAClD,qDAAqD;wBACrD,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;qBAC/B;oBACD,UAAU,CAAC,GAAG,EAAE;wBACZ,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;oBAClC,CAAC,EAAE,EAAE,CAAC,CAAA;gBACV,CAAC;aACJ,CAAC;YACN,OAAO,EAAE,IAAI,yBAAyB,CAAC;gBACnC,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;gBACpC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;aACnC,CAAC;SACL,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QACtB,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA,CAAC,+BAA+B;QAE1F,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA","sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { BaseTelegramClient } from '@mtcute/core'\n\nimport { StubMemoryTelegramStorage } from './storage.js'\nimport { createStub } from './stub.js'\nimport { StubTelegramTransport } from './transport.js'\n\ndescribe('storage stub', () => {\n it('should correctly intercept calls', async () => {\n const log: string[] = []\n\n const client = new BaseTelegramClient({\n apiId: 0,\n apiHash: '',\n logLevel: 0,\n defaultDcs: {\n main: createStub('dcOption', { ipAddress: '1.2.3.4', port: 1234 }),\n media: createStub('dcOption', { ipAddress: '1.2.3.4', port: 5678 }),\n },\n transport: () =>\n new StubTelegramTransport({\n onMessage: (msg) => {\n if (msg.slice(0, 8).reduce((a, b) => a + b, 0) === 0) {\n // should not happen, since we're providing stub keys\n log.push('unauthed_message')\n }\n setTimeout(() => {\n client.close().catch(() => {})\n }, 10)\n },\n }),\n storage: new StubMemoryTelegramStorage({\n hasKeys: true,\n onLoad: () => log.push('load'),\n onSave: () => log.push('save'),\n onDestroy: () => log.push('destroy'),\n onReset: () => log.push('reset'),\n }),\n })\n\n await client.connect()\n await client.call({ _: 'help.getConfig' }).catch(() => {}) // ignore \"client closed\" error\n\n expect(log).toEqual(['load', 'save', 'destroy'])\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/stub.test.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Long from 'long';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { createStub } from './index.js';
|
|
4
|
+
describe('stub', () => {
|
|
5
|
+
it('should correctly generate simple stubs', () => {
|
|
6
|
+
expect(createStub('inputUser', { userId: 123 })).toEqual({
|
|
7
|
+
_: 'inputUser',
|
|
8
|
+
userId: 123,
|
|
9
|
+
accessHash: Long.ZERO,
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
it('should correctly generate stubs for optional fields', () => {
|
|
13
|
+
expect(createStub('updateChannelTooLong')).toEqual({
|
|
14
|
+
_: 'updateChannelTooLong',
|
|
15
|
+
channelId: 0,
|
|
16
|
+
pts: undefined,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it('should correctly generate stubs for boolean flags', () => {
|
|
20
|
+
expect(createStub('account.finishTakeoutSession')).toEqual({
|
|
21
|
+
_: 'account.finishTakeoutSession',
|
|
22
|
+
success: false,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it('should correctly generate stubs for vectors', () => {
|
|
26
|
+
expect(createStub('messageActionChatAddUser')).toEqual({
|
|
27
|
+
_: 'messageActionChatAddUser',
|
|
28
|
+
users: [],
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it('should correctly generate stubs for optional vectors', () => {
|
|
32
|
+
expect(createStub('updateChannelPinnedTopics')).toEqual({
|
|
33
|
+
_: 'updateChannelPinnedTopics',
|
|
34
|
+
channelId: 0,
|
|
35
|
+
order: [],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
it('should correctly generate stubs for nested types', () => {
|
|
39
|
+
expect(createStub('messageActionGroupCallScheduled', { scheduleDate: 123 })).toEqual({
|
|
40
|
+
_: 'messageActionGroupCallScheduled',
|
|
41
|
+
call: {
|
|
42
|
+
_: 'inputGroupCall',
|
|
43
|
+
id: Long.ZERO,
|
|
44
|
+
accessHash: Long.ZERO,
|
|
45
|
+
},
|
|
46
|
+
scheduleDate: 123,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=stub.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stub.test.js","sourceRoot":"","sources":["../../src/stub.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC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gBAAgB;gBACnB,EAAE,EAAE,IAAI,CAAC,IAAI;gBACb,UAAU,EAAE,IAAI,CAAC,IAAI;aACxB;YACD,YAAY,EAAE,GAAG;SACpB,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA","sourcesContent":["import Long from 'long'\nimport { describe, expect, it } from 'vitest'\n\nimport { createStub } from './index.js'\n\ndescribe('stub', () => {\n it('should correctly generate simple stubs', () => {\n expect(createStub('inputUser', { userId: 123 })).toEqual({\n _: 'inputUser',\n userId: 123,\n accessHash: Long.ZERO,\n })\n })\n\n it('should correctly generate stubs for optional fields', () => {\n expect(createStub('updateChannelTooLong')).toEqual({\n _: 'updateChannelTooLong',\n channelId: 0,\n pts: undefined,\n })\n })\n\n it('should correctly generate stubs for boolean flags', () => {\n expect(createStub('account.finishTakeoutSession')).toEqual({\n _: 'account.finishTakeoutSession',\n success: false,\n })\n })\n\n it('should correctly generate stubs for vectors', () => {\n expect(createStub('messageActionChatAddUser')).toEqual({\n _: 'messageActionChatAddUser',\n users: [],\n })\n })\n\n it('should correctly generate stubs for optional vectors', () => {\n expect(createStub('updateChannelPinnedTopics')).toEqual({\n _: 'updateChannelPinnedTopics',\n channelId: 0,\n order: [],\n })\n })\n\n it('should correctly generate stubs for nested types', () => {\n expect(createStub('messageActionGroupCallScheduled', { scheduleDate: 123 })).toEqual({\n _: 'messageActionGroupCallScheduled',\n call: {\n _: 'inputGroupCall',\n id: Long.ZERO,\n accessHash: Long.ZERO,\n },\n scheduleDate: 123,\n })\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { BaseTelegramClient } from '@mtcute/core';
|
|
3
|
+
import { createStub } from './stub.js';
|
|
4
|
+
import { StubTelegramTransport } from './transport.js';
|
|
5
|
+
describe('transport stub', () => {
|
|
6
|
+
it('should correctly intercept calls', async () => {
|
|
7
|
+
const log = [];
|
|
8
|
+
const client = new BaseTelegramClient({
|
|
9
|
+
apiId: 0,
|
|
10
|
+
apiHash: '',
|
|
11
|
+
logLevel: 0,
|
|
12
|
+
defaultDcs: {
|
|
13
|
+
main: createStub('dcOption', { ipAddress: '1.2.3.4', port: 1234 }),
|
|
14
|
+
media: createStub('dcOption', { ipAddress: '1.2.3.4', port: 5678 }),
|
|
15
|
+
},
|
|
16
|
+
transport: () => new StubTelegramTransport({
|
|
17
|
+
onConnect: (dc, testMode) => {
|
|
18
|
+
log.push(`connect ${dc.ipAddress}:${dc.port} test=${testMode}`);
|
|
19
|
+
client.close().catch(() => { });
|
|
20
|
+
},
|
|
21
|
+
onMessage(msg) {
|
|
22
|
+
log.push(`message size=${msg.length}`);
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
await client.connect().catch(() => { }); // ignore "client closed" error
|
|
27
|
+
expect(log).toEqual([
|
|
28
|
+
'message size=40',
|
|
29
|
+
'connect 1.2.3.4:1234 test=false',
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=transport.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.test.js","sourceRoot":"","sources":["../../src/transport.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,GAAG,GAAa,EAAE,CAAA;QAExB,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC;YAClC,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE;gBACR,IAAI,EAAE,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAClE,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aACtE;YACD,SAAS,EAAE,GAAG,EAAE,CACZ,IAAI,qBAAqB,CAAC;gBACtB,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE;oBACxB,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,SAAS,QAAQ,EAAE,CAAC,CAAA;oBAC/D,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;gBAClC,CAAC;gBACD,SAAS,CAAC,GAAG;oBACT,GAAG,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;gBAC1C,CAAC;aACJ,CAAC;SACT,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA,CAAC,+BAA+B;QAEtE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAChB,iBAAiB;YACjB,iCAAiC;SACpC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA","sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { BaseTelegramClient } from '@mtcute/core'\n\nimport { createStub } from './stub.js'\nimport { StubTelegramTransport } from './transport.js'\n\ndescribe('transport stub', () => {\n it('should correctly intercept calls', async () => {\n const log: string[] = []\n\n const client = new BaseTelegramClient({\n apiId: 0,\n apiHash: '',\n logLevel: 0,\n defaultDcs: {\n main: createStub('dcOption', { ipAddress: '1.2.3.4', port: 1234 }),\n media: createStub('dcOption', { ipAddress: '1.2.3.4', port: 5678 }),\n },\n transport: () =>\n new StubTelegramTransport({\n onConnect: (dc, testMode) => {\n log.push(`connect ${dc.ipAddress}:${dc.port} test=${testMode}`)\n client.close().catch(() => {})\n },\n onMessage(msg) {\n log.push(`message size=${msg.length}`)\n },\n }),\n })\n\n await client.connect().catch(() => {}) // ignore \"client closed\" error\n\n expect(log).toEqual([\n 'message size=40', // req_pq_multi\n 'connect 1.2.3.4:1234 test=false',\n ])\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { markedIdToPeer } from './utils.js';
|
|
3
|
+
describe('markedIdToPeer', () => {
|
|
4
|
+
it('should correctly convert user ids', () => {
|
|
5
|
+
expect(markedIdToPeer(12345)).toEqual({ _: 'peerUser', userId: 12345 });
|
|
6
|
+
});
|
|
7
|
+
it('should correctly convert chat ids', () => {
|
|
8
|
+
expect(markedIdToPeer(-12345)).toEqual({ _: 'peerChat', chatId: 12345 });
|
|
9
|
+
});
|
|
10
|
+
it('should correctly convert channel ids', () => {
|
|
11
|
+
expect(markedIdToPeer(-1000000012345)).toEqual({ _: 'peerChannel', channelId: 12345 });
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1F,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA","sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { markedIdToPeer } from './utils.js'\n\ndescribe('markedIdToPeer', () => {\n it('should correctly convert user ids', () => {\n expect(markedIdToPeer(12345)).toEqual({ _: 'peerUser', userId: 12345 })\n })\n\n it('should correctly convert chat ids', () => {\n expect(markedIdToPeer(-12345)).toEqual({ _: 'peerChat', chatId: 12345 })\n })\n\n it('should correctly convert channel ids', () => {\n expect(markedIdToPeer(-1000000012345)).toEqual({ _: 'peerChannel', channelId: 12345 })\n })\n})\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Test utilities for mtcute",
|
|
5
5
|
"author": "Alina Sireneva <alina@tei.su>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"long": "5.2.3"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@mtcute/core": "^0.1.
|
|
15
|
-
"@mtcute/tl": "^*"
|
|
14
|
+
"@mtcute/core": "^0.1.2",
|
|
15
|
+
"@mtcute/tl": "^*",
|
|
16
|
+
"vitest": "^0.34.6"
|
|
16
17
|
},
|
|
17
18
|
"module": "esm/index.js",
|
|
18
19
|
"exports": {
|