MCPcopy
hub / github.com/signalapp/Signal-Desktop / init

Method init

ts/test-mock/bootstrap.node.ts:274–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272 }
273
274 public async init(): Promise<void> {
275 debug('initializing');
276
277 if (this.#options.server === undefined) {
278 await this.server.listen(0);
279
280 const { port } = this.server.address();
281 debug('started server on port=%d', port);
282 } else {
283 debug('existing server listening on port = ', this.server.address().port);
284 }
285
286 const totalContactCount =
287 this.#options.contactCount +
288 this.#options.contactsWithoutProfileKey +
289 this.#options.unknownContactCount;
290
291 const allContacts = await Promise.all(
292 this.#options.contactNames
293 .slice(0, totalContactCount)
294 .map(async profileName => {
295 const primary = await this.server.createPrimaryDevice({
296 profileName,
297 });
298
299 for (let i = 0; i < this.#options.linkedDevices; i += 1) {
300 // oxlint-disable-next-line no-await-in-loop
301 await this.server.createSecondaryDevice(primary);
302 }
303
304 return primary;
305 })
306 );
307
308 this.#privContacts = allContacts.splice(0, this.#options.contactCount);
309 this.#privContactsWithoutProfileKey = allContacts.splice(
310 0,
311 this.#options.contactsWithoutProfileKey
312 );
313 this.#privUnknownContacts = allContacts.splice(
314 0,
315 this.#options.unknownContactCount
316 );
317
318 this.#privPhone = await this.server.createPrimaryDevice({
319 profileName: 'Myself',
320 contacts: this.contacts,
321 contactsWithoutProfileKey: this.contactsWithoutProfileKey,
322 });
323 if (this.#options.useLegacyStorageEncryption) {
324 this.#privPhone.storageRecordIkm = undefined;
325 }
326
327 this.#storagePath = await fs.mkdtemp(
328 path.join(os.tmpdir(), 'mock-signal-')
329 );
330
331 DEFAULT_REMOTE_CONFIG.forEach(([key, value]) =>

Callers 15

runBenchmarkMethod · 0.95
mochaGlobalSetupFunction · 0.95
initStorageFunction · 0.95
startAppFunction · 0.45
onEmptyFunction · 0.45
story_test.node.tsFile · 0.45

Calls 2

listenMethod · 0.80
debugFunction · 0.50

Tested by

no test coverage detected