



























@@ -81,6 +81,19 @@ type MatrixQaDestructiveSetup = {
8181seededEventId: string;
8282};
838384+async function cleanupMatrixQaTempDevices(
85+client: MatrixQaE2eeScenarioClient,
86+deviceIds: Array<string | null | undefined>,
87+): Promise<void> {
88+await client.stop().catch(() => undefined);
89+const uniqueDeviceIds = [
90+ ...new Set(deviceIds.filter((deviceId): deviceId is string => !!deviceId)),
91+];
92+if (uniqueDeviceIds.length > 0) {
93+await client.deleteOwnDevices(uniqueDeviceIds).catch(() => undefined);
94+}
95+}
96+8497function requireMatrixQaE2eeOutputDir(context: MatrixQaScenarioContext) {
8598if (!context.outputDir) {
8699throw new Error("Matrix E2EE destructive QA scenarios require an output directory");
@@ -668,8 +681,7 @@ export async function runMatrixQaE2eeStateLossExternalRecoveryKeyScenario(
668681};
669682} finally {
670683await cli.dispose().catch(() => undefined);
671-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
672-await setup.owner.stop().catch(() => undefined);
684+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
673685}
674686}
675687@@ -748,8 +760,7 @@ export async function runMatrixQaE2eeStateLossStoredRecoveryKeyScenario(
748760};
749761} finally {
750762await cli.dispose().catch(() => undefined);
751-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
752-await setup.owner.stop().catch(() => undefined);
763+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
753764}
754765}
755766@@ -793,8 +804,7 @@ export async function runMatrixQaE2eeStateLossNoRecoveryKeyScenario(
793804};
794805} finally {
795806await cli.dispose().catch(() => undefined);
796-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
797-await setup.owner.stop().catch(() => undefined);
807+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
798808}
799809}
800810@@ -863,8 +873,7 @@ export async function runMatrixQaE2eeStaleRecoveryKeyAfterBackupResetScenario(
863873};
864874} finally {
865875await cli.dispose().catch(() => undefined);
866-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
867-await setup.owner.stop().catch(() => undefined);
876+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
868877}
869878}
870879@@ -1026,8 +1035,7 @@ export async function runMatrixQaE2eeServerBackupDeletedLocalReuploadRestoresSce
10261035};
10271036} finally {
10281037await cli.dispose().catch(() => undefined);
1029-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
1030-await setup.owner.stop().catch(() => undefined);
1038+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
10311039}
10321040}
10331041@@ -1101,8 +1109,7 @@ export async function runMatrixQaE2eeCorruptCryptoIdbSnapshotScenario(
11011109};
11021110} finally {
11031111await cli.dispose().catch(() => undefined);
1104-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
1105-await setup.owner.stop().catch(() => undefined);
1112+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
11061113}
11071114}
11081115@@ -1141,6 +1148,7 @@ export async function runMatrixQaE2eeServerDeviceDeletedLocalStateIntactScenario
11411148assertMatrixQaCliBackupRestoreSucceeded(restored.payload, "deleted-device preflight");
11421149await setup.owner.deleteOwnDevices([device.deviceId]);
11431150const ownerDevicesAfterDelete = await setup.owner.listOwnDevices();
1151+await setup.owner.stop().catch(() => undefined);
11441152const defaultStatus = await runMatrixQaCliJson<MatrixQaCliVerificationStatus>({
11451153allowNonZero: true,
11461154args: ["matrix", "verify", "status", "--account", "deleted-device", "--json"],
@@ -1238,6 +1246,7 @@ export async function runMatrixQaE2eeServerDeviceDeletedReloginRecoversScenario(
1238124612391247await setup.owner.deleteOwnDevices([deleted.device.deviceId]);
12401248const ownerDevicesAfterDelete = await setup.owner.listOwnDevices();
1249+await setup.owner.stop().catch(() => undefined);
12411250const defaultStatus = await runMatrixQaCliJson<MatrixQaCliVerificationStatus>({
12421251allowNonZero: true,
12431252args: ["matrix", "verify", "status", "--account", "deleted-device-recovery", "--json"],
@@ -1322,12 +1331,11 @@ export async function runMatrixQaE2eeServerDeviceDeletedReloginRecoversScenario(
13221331};
13231332} finally {
13241333await replacement?.cli.dispose().catch(() => undefined);
1325-if (replacement?.device.deviceId) {
1326-await setup.owner.deleteOwnDevices([replacement.device.deviceId]).catch(() => undefined);
1327-}
13281334await deleted.cli.dispose().catch(() => undefined);
1329-await setup.owner.deleteOwnDevices([deleted.device.deviceId]).catch(() => undefined);
1330-await setup.owner.stop().catch(() => undefined);
1335+await cleanupMatrixQaTempDevices(setup.owner, [
1336+replacement?.device.deviceId,
1337+deleted.device.deviceId,
1338+]);
13311339}
13321340}
13331341@@ -1566,6 +1574,7 @@ export async function runMatrixQaE2eeWrongAccountRecoveryKeyScenario(
15661574};
15671575} finally {
15681576await cli?.dispose().catch(() => undefined);
1577+await observer.stop().catch(() => undefined);
15691578if (device) {
15701579await observer.deleteOwnDevices([device.deviceId]).catch(() => undefined);
15711580}
@@ -1627,7 +1636,6 @@ export async function runMatrixQaE2eeHistoryExistsBackupEmptyScenario(
16271636};
16281637} finally {
16291638await cli.dispose().catch(() => undefined);
1630-await setup.owner.deleteOwnDevices([device.deviceId]).catch(() => undefined);
1631-await setup.owner.stop().catch(() => undefined);
1639+await cleanupMatrixQaTempDevices(setup.owner, [device.deviceId]);
16321640}
16331641}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。