Test processing of unprocessed envelopes
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
2c01e6f4b8
commit
83b076b5c4
7 changed files with 113 additions and 10 deletions
|
@ -1005,9 +1005,7 @@ async function createWindow() {
|
||||||
mainWindow.webContents.send('ci:event', 'db-initialized', {});
|
mainWindow.webContents.send('ci:event', 'db-initialized', {});
|
||||||
|
|
||||||
const shouldShowWindow =
|
const shouldShowWindow =
|
||||||
!app.getLoginItemSettings().wasOpenedAsHidden &&
|
!app.getLoginItemSettings().wasOpenedAsHidden && !startInTray;
|
||||||
!startInTray &&
|
|
||||||
!config.get<boolean>('ciIsBackupIntegration');
|
|
||||||
|
|
||||||
if (shouldShowWindow) {
|
if (shouldShowWindow) {
|
||||||
getLogger().info('showing main window');
|
getLogger().info('showing main window');
|
||||||
|
@ -2748,12 +2746,11 @@ ipc.on('get-config', async event => {
|
||||||
: getEnvironment(),
|
: getEnvironment(),
|
||||||
isMockTestEnvironment: Boolean(process.env.MOCK_TEST),
|
isMockTestEnvironment: Boolean(process.env.MOCK_TEST),
|
||||||
ciMode,
|
ciMode,
|
||||||
|
ciForceUnprocessed: config.get<boolean>('ciForceUnprocessed'),
|
||||||
devTools: defaultWebPrefs.devTools,
|
devTools: defaultWebPrefs.devTools,
|
||||||
// Should be already computed and cached at this point
|
// Should be already computed and cached at this point
|
||||||
dnsFallback: await getDNSFallback(),
|
dnsFallback: await getDNSFallback(),
|
||||||
disableIPv6: DISABLE_IPV6,
|
disableIPv6: DISABLE_IPV6,
|
||||||
ciBackupPath: config.get<string | null>('ciBackupPath') || undefined,
|
|
||||||
ciIsBackupIntegration: config.get<boolean>('ciIsBackupIntegration'),
|
|
||||||
nodeVersion: process.versions.node,
|
nodeVersion: process.versions.node,
|
||||||
hostname: os.hostname(),
|
hostname: os.hostname(),
|
||||||
osRelease: os.release(),
|
osRelease: os.release(),
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
"registrationChallengeUrl": "https://signalcaptchas.org/staging/registration/generate.html",
|
"registrationChallengeUrl": "https://signalcaptchas.org/staging/registration/generate.html",
|
||||||
"updatesEnabled": false,
|
"updatesEnabled": false,
|
||||||
"ciMode": false,
|
"ciMode": false,
|
||||||
"ciBackupPath": null,
|
"ciForceUnprocessed": false,
|
||||||
"ciIsBackupIntegration": false,
|
|
||||||
"forcePreloadBundle": false,
|
"forcePreloadBundle": false,
|
||||||
"openDevTools": false,
|
"openDevTools": false,
|
||||||
"buildCreation": 0,
|
"buildCreation": 0,
|
||||||
|
|
8
ts/CI.ts
8
ts/CI.ts
|
@ -42,13 +42,18 @@ export type CIType = {
|
||||||
unlink: () => void;
|
unlink: () => void;
|
||||||
print: (...args: ReadonlyArray<unknown>) => void;
|
print: (...args: ReadonlyArray<unknown>) => void;
|
||||||
resetReleaseNotesFetcher(): void;
|
resetReleaseNotesFetcher(): void;
|
||||||
|
forceUnprocessed: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetCIOptionsType = Readonly<{
|
export type GetCIOptionsType = Readonly<{
|
||||||
deviceName: string;
|
deviceName: string;
|
||||||
|
forceUnprocessed: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export function getCI({ deviceName }: GetCIOptionsType): CIType {
|
export function getCI({
|
||||||
|
deviceName,
|
||||||
|
forceUnprocessed,
|
||||||
|
}: GetCIOptionsType): CIType {
|
||||||
const eventListeners = new Map<string, Array<ResolveType>>();
|
const eventListeners = new Map<string, Array<ResolveType>>();
|
||||||
const completedEvents = new Map<string, Array<unknown>>();
|
const completedEvents = new Map<string, Array<unknown>>();
|
||||||
|
|
||||||
|
@ -208,5 +213,6 @@ export function getCI({ deviceName }: GetCIOptionsType): CIType {
|
||||||
getPendingEventCount,
|
getPendingEventCount,
|
||||||
print,
|
print,
|
||||||
resetReleaseNotesFetcher,
|
resetReleaseNotesFetcher,
|
||||||
|
forceUnprocessed,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
96
ts/test-mock/messaging/unprocessed_test.ts
Normal file
96
ts/test-mock/messaging/unprocessed_test.ts
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
// Copyright 2025 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import createDebug from 'debug';
|
||||||
|
import { StorageState } from '@signalapp/mock-server';
|
||||||
|
|
||||||
|
import * as durations from '../../util/durations';
|
||||||
|
import type { App } from '../playwright';
|
||||||
|
import { Bootstrap } from '../bootstrap';
|
||||||
|
|
||||||
|
export const debug = createDebug('mock:test:unprocessed');
|
||||||
|
|
||||||
|
describe('unprocessed', function (this: Mocha.Suite) {
|
||||||
|
this.timeout(durations.MINUTE);
|
||||||
|
|
||||||
|
let bootstrap: Bootstrap;
|
||||||
|
let app: App;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
bootstrap = new Bootstrap({ contactCount: 1 });
|
||||||
|
|
||||||
|
await bootstrap.init();
|
||||||
|
|
||||||
|
let state = StorageState.getEmpty();
|
||||||
|
|
||||||
|
const {
|
||||||
|
phone,
|
||||||
|
contacts: [alice],
|
||||||
|
} = bootstrap;
|
||||||
|
|
||||||
|
state = state.addContact(alice, {
|
||||||
|
identityKey: alice.publicKey.serialize(),
|
||||||
|
profileKey: alice.profileKey.serialize(),
|
||||||
|
whitelisted: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
state = state.pin(alice);
|
||||||
|
await phone.setStorageState(state);
|
||||||
|
|
||||||
|
app = await bootstrap.link();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async function (this: Mocha.Context) {
|
||||||
|
if (!bootstrap) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await bootstrap.maybeSaveLogs(this.currentTest, app);
|
||||||
|
await app.close();
|
||||||
|
await bootstrap.teardown();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('generates and loads unprocessed envelopes', async () => {
|
||||||
|
const {
|
||||||
|
desktop,
|
||||||
|
contacts: [alice],
|
||||||
|
} = bootstrap;
|
||||||
|
|
||||||
|
debug('closing');
|
||||||
|
await app.close();
|
||||||
|
|
||||||
|
debug('queueing messages');
|
||||||
|
const sends = new Array<Promise<void>>();
|
||||||
|
for (let i = 0; i < 100; i += 1) {
|
||||||
|
sends.push(
|
||||||
|
alice.sendText(desktop, `hello: ${i}`, {
|
||||||
|
timestamp: bootstrap.getTimestamp(),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('starting app with unprocessed forced');
|
||||||
|
[app] = await Promise.all([
|
||||||
|
bootstrap.startApp({
|
||||||
|
ciForceUnprocessed: true,
|
||||||
|
}),
|
||||||
|
...sends,
|
||||||
|
]);
|
||||||
|
|
||||||
|
debug('waiting for the window');
|
||||||
|
await app.getWindow();
|
||||||
|
|
||||||
|
debug('restarting normally');
|
||||||
|
await app.close();
|
||||||
|
app = await bootstrap.startApp();
|
||||||
|
|
||||||
|
const page = await app.getWindow();
|
||||||
|
|
||||||
|
debug('opening conversation');
|
||||||
|
await page
|
||||||
|
.locator(`[data-testid="${alice.device.aci}"] >> "${alice.profileName}"`)
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await page.locator('.module-message__text >> "hello: 5"').waitFor();
|
||||||
|
});
|
||||||
|
});
|
|
@ -1144,6 +1144,11 @@ export default class MessageReceiver
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force save of unprocessed envelopes for testing
|
||||||
|
if (window.SignalCI?.forceUnprocessed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Now, queue and process decrypted envelopes. We drop the promise so that the next
|
// Now, queue and process decrypted envelopes. We drop the promise so that the next
|
||||||
// decryptAndCacheBatch batch does not have to wait for the decrypted envelopes to be
|
// decryptAndCacheBatch batch does not have to wait for the decrypted envelopes to be
|
||||||
// processed, which can be an asynchronous blocking operation
|
// processed, which can be an asynchronous blocking operation
|
||||||
|
|
|
@ -40,11 +40,10 @@ export const rendererConfigSchema = z.object({
|
||||||
contentProxyUrl: configRequiredStringSchema,
|
contentProxyUrl: configRequiredStringSchema,
|
||||||
crashDumpsPath: configRequiredStringSchema,
|
crashDumpsPath: configRequiredStringSchema,
|
||||||
ciMode: z.enum(['full', 'benchmark']).or(z.literal(false)),
|
ciMode: z.enum(['full', 'benchmark']).or(z.literal(false)),
|
||||||
|
ciForceUnprocessed: z.boolean(),
|
||||||
devTools: z.boolean(),
|
devTools: z.boolean(),
|
||||||
disableIPv6: z.boolean(),
|
disableIPv6: z.boolean(),
|
||||||
dnsFallback: DNSFallbackSchema,
|
dnsFallback: DNSFallbackSchema,
|
||||||
ciBackupPath: configOptionalStringSchema,
|
|
||||||
ciIsBackupIntegration: z.boolean(),
|
|
||||||
environment: environmentSchema,
|
environment: environmentSchema,
|
||||||
isMockTestEnvironment: z.boolean(),
|
isMockTestEnvironment: z.boolean(),
|
||||||
homePath: configRequiredStringSchema,
|
homePath: configRequiredStringSchema,
|
||||||
|
|
|
@ -19,5 +19,6 @@ if (config.ciMode) {
|
||||||
const { getCI } = require('../../CI');
|
const { getCI } = require('../../CI');
|
||||||
window.SignalCI = getCI({
|
window.SignalCI = getCI({
|
||||||
deviceName: window.getTitle(),
|
deviceName: window.getTitle(),
|
||||||
|
forceUnprocessed: config.ciForceUnprocessed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue