






















@@ -1907,98 +1907,80 @@ describe("matrix live qa scenarios", () => {
1907190719081908const scenario = requireMatrixQaScenario("matrix-e2ee-sync-state-loss-crypto-intact");
190919091910-await expect(
1911-runMatrixQaScenario(scenario, {
1912- ...matrixQaScenarioContext(),
1913-driverDeviceId: "DRIVER",
1914-gatewayRuntimeEnv: {
1915-OPENCLAW_CONFIG_PATH: gatewayConfigPath,
1916-PATH: process.env.PATH,
1917-},
1918-gatewayStateDir: stateRoot,
1919-observerDeviceId: "OBSERVER",
1920-outputDir: stateRoot,
1921-restartGatewayAfterStateMutation: async (mutateState) => {
1922-callOrder.push("hard-restart");
1923-await mutateState({ stateDir: stateRoot });
1924-const config = JSON.parse(await readFile(gatewayConfigPath, "utf8")) as {
1925-channels: {
1926-matrix: {
1927-accounts: Record<string, { groups?: Record<string, unknown>; userId?: string }>;
1928-defaultAccount?: string;
1929-};
1910+const result = await runMatrixQaScenario(scenario, {
1911+ ...matrixQaScenarioContext(),
1912+driverDeviceId: "DRIVER",
1913+gatewayRuntimeEnv: {
1914+OPENCLAW_CONFIG_PATH: gatewayConfigPath,
1915+PATH: process.env.PATH,
1916+},
1917+gatewayStateDir: stateRoot,
1918+observerDeviceId: "OBSERVER",
1919+outputDir: stateRoot,
1920+restartGatewayAfterStateMutation: async (mutateState) => {
1921+callOrder.push("hard-restart");
1922+await mutateState({ stateDir: stateRoot });
1923+const config = JSON.parse(await readFile(gatewayConfigPath, "utf8")) as {
1924+channels: {
1925+matrix: {
1926+accounts: Record<string, { groups?: Record<string, unknown>; userId?: string }>;
1927+defaultAccount?: string;
19301928};
19311929};
1932-hardRestartAccounts.push({
1933-accounts: config.channels.matrix.accounts,
1934-defaultAccount: config.channels.matrix.defaultAccount,
1935-});
1936-},
1937-sutAccountId: "sut",
1938-sutDeviceId: "SUT",
1939- waitGatewayAccountReady,
1940-}),
1941-).resolves.toMatchObject({
1942-artifacts: {
1943-deletedSyncStorePath: syncStorePath,
1944-driverEventId: "$driver-trigger",
1945-replyEventId: "$sut-decrypted-reply",
1946-roomKey: "e2ee-sync-state-loss-crypto-intact-recovery",
1930+};
1931+hardRestartAccounts.push({
1932+accounts: config.channels.matrix.accounts,
1933+defaultAccount: config.channels.matrix.defaultAccount,
1934+});
19471935},
1936+sutAccountId: "sut",
1937+sutDeviceId: "SUT",
1938+ waitGatewayAccountReady,
19481939});
1940+const artifacts = result.artifacts as {
1941+deletedSyncStorePath?: unknown;
1942+driverEventId?: unknown;
1943+replyEventId?: unknown;
1944+roomKey?: unknown;
1945+};
1946+expect(artifacts.deletedSyncStorePath).toBe(syncStorePath);
1947+expect(artifacts.driverEventId).toBe("$driver-trigger");
1948+expect(artifacts.replyEventId).toBe("$sut-decrypted-reply");
1949+expect(artifacts.roomKey).toBe("e2ee-sync-state-loss-crypto-intact-recovery");
1949195019501951await expectPathMissing(syncStorePath);
1951-expect(registerWithToken).toHaveBeenCalledWith(
1952-expect.objectContaining({
1953-registrationToken: "registration-token",
1954-}),
1955-);
1952+expect(registerWithToken.mock.calls[0]?.[0]?.registrationToken).toBe("registration-token");
19561953expect(createPrivateRoom).toHaveBeenCalledWith({
19571954encrypted: true,
19581955inviteUserIds: ["@observer:matrix-qa.test", "@sync-gateway:matrix-qa.test"],
19591956name: "Matrix QA E2EE Sync State Loss Recovery Room",
19601957});
19611958expect(observerJoinRoom).toHaveBeenCalledWith("!recovery:matrix-qa.test");
19621959expect(sutJoinRoom).toHaveBeenCalledWith("!recovery:matrix-qa.test");
1963-expect(hardRestartAccounts).toEqual([
1964-{
1965-accounts: {
1966-"sync-state-loss-gateway": expect.objectContaining({
1967-groups: {
1968-"!recovery:matrix-qa.test": {
1969-enabled: true,
1970-requireMention: true,
1971-},
1972-},
1973-userId: "@sync-gateway:matrix-qa.test",
1974-}),
1975-},
1976-defaultAccount: "sync-state-loss-gateway",
1977-},
1978-{
1979-accounts: {
1980-"sync-state-loss-gateway": expect.objectContaining({
1981-groups: {
1982-"!recovery:matrix-qa.test": {
1983-enabled: true,
1984-requireMention: true,
1985-},
1986-},
1987-userId: "@sync-gateway:matrix-qa.test",
1988-}),
1989-},
1990-defaultAccount: "sync-state-loss-gateway",
1991-},
1992-{
1993-accounts: {
1994-sut: expect.objectContaining({
1995-groups: originalGroups,
1996-userId: "@sut:matrix-qa.test",
1997-}),
1998-},
1999-defaultAccount: "sut",
1960+expect(hardRestartAccounts).toHaveLength(3);
1961+const recoveryGroup = {
1962+"!recovery:matrix-qa.test": {
1963+enabled: true,
1964+requireMention: true,
20001965},
2001-]);
1966+};
1967+expect(hardRestartAccounts[0]?.defaultAccount).toBe("sync-state-loss-gateway");
1968+expect(hardRestartAccounts[0]?.accounts["sync-state-loss-gateway"]?.groups).toEqual(
1969+recoveryGroup,
1970+);
1971+expect(hardRestartAccounts[0]?.accounts["sync-state-loss-gateway"]?.userId).toBe(
1972+"@sync-gateway:matrix-qa.test",
1973+);
1974+expect(hardRestartAccounts[1]?.defaultAccount).toBe("sync-state-loss-gateway");
1975+expect(hardRestartAccounts[1]?.accounts["sync-state-loss-gateway"]?.groups).toEqual(
1976+recoveryGroup,
1977+);
1978+expect(hardRestartAccounts[1]?.accounts["sync-state-loss-gateway"]?.userId).toBe(
1979+"@sync-gateway:matrix-qa.test",
1980+);
1981+expect(hardRestartAccounts[2]?.defaultAccount).toBe("sut");
1982+expect(hardRestartAccounts[2]?.accounts.sut?.groups).toEqual(originalGroups);
1983+expect(hardRestartAccounts[2]?.accounts.sut?.userId).toBe("@sut:matrix-qa.test");
20021984expect(callOrder).toEqual([
20031985"create-room",
20041986"observer-join",
@@ -2017,12 +1999,9 @@ describe("matrix live qa scenarios", () => {
20171999mentionUserIds: ["@sync-gateway:matrix-qa.test"],
20182000roomId: "!recovery:matrix-qa.test",
20192001});
2020-expect(rawWaitForRoomEvent).toHaveBeenCalledWith(
2021-expect.objectContaining({
2022-roomId: "!recovery:matrix-qa.test",
2023-since: "raw-driver-sync-start",
2024-}),
2025-);
2002+const waitParams = rawWaitForRoomEvent.mock.calls[0]?.[0];
2003+expect(waitParams?.roomId).toBe("!recovery:matrix-qa.test");
2004+expect(waitParams?.since).toBe("raw-driver-sync-start");
20262005const finalConfig = JSON.parse(await readFile(gatewayConfigPath, "utf8")) as {
20272006channels: {
20282007matrix: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。