Fetch PNI group credentials

This commit is contained in:
Fedor Indutny 2022-07-08 13:46:25 -07:00 committed by GitHub
parent b9ba732724
commit a450e13a99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 1911 additions and 875 deletions

View file

@ -2,16 +2,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-await-in-loop, no-console */
import assert from 'assert';
import type { PrimaryDevice } from '@signalapp/mock-server';
import {
Bootstrap,
debug,
saveLogs,
stats,
RUN_COUNT,
DISCARD_COUNT,
} from './fixtures';
import type { App } from './fixtures';
import { Bootstrap, debug, stats, RUN_COUNT, DISCARD_COUNT } from './fixtures';
const CONVERSATION_SIZE = 1000; // messages
const DELAY = 50; // milliseconds
@ -22,9 +17,10 @@ const DELAY = 50; // milliseconds
});
await bootstrap.init();
const app = await bootstrap.link();
let app: App | undefined;
try {
app = await bootstrap.link();
const { server, contacts, phone, desktop } = bootstrap;
const [first, second] = contacts;
@ -65,6 +61,7 @@ const DELAY = 50; // milliseconds
};
const measure = async (): Promise<void> => {
assert(app);
const window = await app.getWindow();
const leftPane = window.locator('.left-pane-wrapper');
@ -102,10 +99,10 @@ const DELAY = 50; // milliseconds
await Promise.all([sendQueue(), measure()]);
} catch (error) {
await saveLogs(bootstrap);
await bootstrap.saveLogs();
throw error;
} finally {
await app.close();
await app?.close();
await bootstrap.teardown();
}
})();

View file

@ -3,8 +3,6 @@
/* eslint-disable no-console */
import createDebug from 'debug';
import fs from 'fs/promises';
import path from 'path';
import { Bootstrap } from '../bootstrap';
@ -63,19 +61,6 @@ export function stats(
return result;
}
export async function saveLogs(bootstrap: Bootstrap): Promise<void> {
const { ARTIFACTS_DIR } = process.env;
if (!ARTIFACTS_DIR) {
console.error('Not saving logs. Please set ARTIFACTS_DIR env variable');
return;
}
await fs.mkdir(ARTIFACTS_DIR, { recursive: true });
const { logsDir } = bootstrap;
await fs.rename(logsDir, path.join(ARTIFACTS_DIR, 'logs'));
}
// Can happen if electron exits prematurely
process.on('unhandledRejection', reason => {
console.error('Unhandled rejection:');

View file

@ -9,10 +9,11 @@ import {
EnvelopeType,
ReceiptType,
} from '@signalapp/mock-server';
import type { App } from './fixtures';
import {
Bootstrap,
debug,
saveLogs,
stats,
RUN_COUNT,
GROUP_SIZE,
@ -44,9 +45,11 @@ const LAST_MESSAGE = 'start sending messages now';
.pinGroup(group)
);
const app = await bootstrap.link();
let app: App | undefined;
try {
app = await bootstrap.link();
const { server, desktop } = bootstrap;
const [first] = members;
@ -179,10 +182,10 @@ const LAST_MESSAGE = 'start sending messages now';
console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) });
} catch (error) {
await saveLogs(bootstrap);
await bootstrap.saveLogs();
throw error;
} finally {
await app.close();
await app?.close();
await bootstrap.teardown();
}
})();

View file

@ -6,14 +6,8 @@ import assert from 'assert';
import { ReceiptType } from '@signalapp/mock-server';
import {
Bootstrap,
debug,
saveLogs,
stats,
RUN_COUNT,
DISCARD_COUNT,
} from './fixtures';
import type { App } from './fixtures';
import { Bootstrap, debug, stats, RUN_COUNT, DISCARD_COUNT } from './fixtures';
const CONVERSATION_SIZE = 500; // messages
@ -25,9 +19,11 @@ const LAST_MESSAGE = 'start sending messages now';
});
await bootstrap.init();
const app = await bootstrap.link();
let app: App | undefined;
try {
app = await bootstrap.link();
const { server, contacts, phone, desktop } = bootstrap;
const [first] = contacts;
@ -136,10 +132,10 @@ const LAST_MESSAGE = 'start sending messages now';
console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) });
} catch (error) {
await saveLogs(bootstrap);
await bootstrap.saveLogs();
throw error;
} finally {
await app.close();
await app?.close();
await bootstrap.teardown();
}
})();

View file

@ -4,7 +4,7 @@
import { ReceiptType } from '@signalapp/mock-server';
import { debug, Bootstrap, saveLogs, stats, RUN_COUNT } from './fixtures';
import { debug, Bootstrap, stats, RUN_COUNT } from './fixtures';
const MESSAGE_BATCH_SIZE = 1000; // messages
@ -128,7 +128,7 @@ const ENABLE_RECEIPTS = Boolean(process.env.ENABLE_RECEIPTS);
console.log('stats info=%j', { messagesPerSec: stats(messagesPerSec) });
}
} catch (error) {
await saveLogs(bootstrap);
await bootstrap.saveLogs();
throw error;
} finally {
await bootstrap.teardown();

View file

@ -4,7 +4,8 @@
import { StorageState } from '@signalapp/mock-server';
import { Bootstrap, saveLogs } from './fixtures';
import type { App } from './fixtures';
import { Bootstrap } from './fixtures';
const CONTACT_COUNT = 1000;
@ -43,8 +44,9 @@ const CONTACT_COUNT = 1000;
await phone.setStorageState(state);
const start = Date.now();
const app = await bootstrap.link();
let app: App | undefined;
try {
app = await bootstrap.link();
const window = await app.getWindow();
const leftPane = window.locator('.left-pane-wrapper');
@ -58,10 +60,10 @@ const CONTACT_COUNT = 1000;
const duration = Date.now() - start;
console.log(`Took: ${(duration / 1000).toFixed(2)} seconds`);
} catch (error) {
await saveLogs(bootstrap);
await bootstrap.saveLogs();
throw error;
} finally {
await app.close();
await app?.close();
await bootstrap.teardown();
}
})();