






















@@ -5841,59 +5841,62 @@ describe("matrix live qa scenarios", () => {
5841584158425842const scenario = requireMatrixQaScenario("matrix-e2ee-cli-setup-then-gateway-reply");
584358435844-await expect(
5845-runMatrixQaScenario(scenario, {
5846- ...matrixQaScenarioContext(),
5847-driverDeviceId: "DRIVERDEVICE",
5848-driverPassword: "driver-password",
5849-gatewayRuntimeEnv: {
5850-OPENCLAW_CONFIG_PATH: gatewayConfigPath,
5851-OPENCLAW_STATE_DIR: "/tmp/gateway-state",
5852-PATH: process.env.PATH,
5853-},
5854- outputDir,
5855- patchGatewayConfig,
5856- restartGatewayAfterStateMutation,
5857- waitGatewayAccountReady,
5858-sutAccountId: "sut",
5859-sutDeviceId: "SUTDEVICE",
5860-sutPassword: "sut-password",
5861-topology: {
5862-defaultRoomId: "!main:matrix-qa.test",
5863-defaultRoomKey: "main",
5864-rooms: [
5865-{
5866-encrypted: true,
5867-key: matrixQaE2eeRoomKey("matrix-e2ee-cli-setup-then-gateway-reply"),
5868-kind: "group",
5869-memberRoles: ["driver", "observer", "sut"],
5870-memberUserIds: [
5871-"@driver:matrix-qa.test",
5872-"@observer:matrix-qa.test",
5873-"@sut:matrix-qa.test",
5874-],
5875-name: "E2EE",
5876-requireMention: true,
5877-roomId: "!e2ee:matrix-qa.test",
5878-},
5879-],
5880-},
5881-}),
5882-).resolves.toMatchObject({
5883-artifacts: {
5884-accountId: "cli-setup-gateway",
5885-cliDeviceId: "CLIGATEWAYDEVICE",
5886-driverUserId: "@cli-driver:matrix-qa.test",
5887-gatewayReply: {
5888-eventId: "$gateway-reply",
5889-tokenMatched: true,
5890-},
5891-gatewayUserId: "@cli-gateway:matrix-qa.test",
5892-roomId: "!isolated-e2ee:matrix-qa.test",
5893-setupSuccess: true,
5894-verificationBootstrapSuccess: true,
5844+const result = await runMatrixQaScenario(scenario, {
5845+ ...matrixQaScenarioContext(),
5846+driverDeviceId: "DRIVERDEVICE",
5847+driverPassword: "driver-password",
5848+gatewayRuntimeEnv: {
5849+OPENCLAW_CONFIG_PATH: gatewayConfigPath,
5850+OPENCLAW_STATE_DIR: "/tmp/gateway-state",
5851+PATH: process.env.PATH,
5852+},
5853+ outputDir,
5854+ patchGatewayConfig,
5855+ restartGatewayAfterStateMutation,
5856+ waitGatewayAccountReady,
5857+sutAccountId: "sut",
5858+sutDeviceId: "SUTDEVICE",
5859+sutPassword: "sut-password",
5860+topology: {
5861+defaultRoomId: "!main:matrix-qa.test",
5862+defaultRoomKey: "main",
5863+rooms: [
5864+{
5865+encrypted: true,
5866+key: matrixQaE2eeRoomKey("matrix-e2ee-cli-setup-then-gateway-reply"),
5867+kind: "group",
5868+memberRoles: ["driver", "observer", "sut"],
5869+memberUserIds: [
5870+"@driver:matrix-qa.test",
5871+"@observer:matrix-qa.test",
5872+"@sut:matrix-qa.test",
5873+],
5874+name: "E2EE",
5875+requireMention: true,
5876+roomId: "!e2ee:matrix-qa.test",
5877+},
5878+],
58955879},
58965880});
5881+const artifacts = result.artifacts as {
5882+accountId?: unknown;
5883+cliDeviceId?: unknown;
5884+driverUserId?: unknown;
5885+gatewayReply?: { eventId?: unknown; tokenMatched?: unknown };
5886+gatewayUserId?: unknown;
5887+roomId?: unknown;
5888+setupSuccess?: unknown;
5889+verificationBootstrapSuccess?: unknown;
5890+};
5891+expect(artifacts.accountId).toBe("cli-setup-gateway");
5892+expect(artifacts.cliDeviceId).toBe("CLIGATEWAYDEVICE");
5893+expect(artifacts.driverUserId).toBe("@cli-driver:matrix-qa.test");
5894+expect(artifacts.gatewayReply?.eventId).toBe("$gateway-reply");
5895+expect(artifacts.gatewayReply?.tokenMatched).toBe(true);
5896+expect(artifacts.gatewayUserId).toBe("@cli-gateway:matrix-qa.test");
5897+expect(artifacts.roomId).toBe("!isolated-e2ee:matrix-qa.test");
5898+expect(artifacts.setupSuccess).toBe(true);
5899+expect(artifacts.verificationBootstrapSuccess).toBe(true);
58975900const finalGatewayConfig = JSON.parse(await readFile(gatewayConfigPath, "utf8")) as {
58985901channels: {
58995902matrix: {
@@ -5906,26 +5909,28 @@ describe("matrix live qa scenarios", () => {
59065909expect(Object.keys(finalGatewayConfig.channels.matrix.accounts)).toEqual([
59075910"cli-setup-gateway",
59085911]);
5909-expect(finalGatewayConfig.channels.matrix.accounts["cli-setup-gateway"]).toMatchObject({
5910-encryption: true,
5911-setupBootstrapMarker: "preserved",
5912-});
5912+const finalGatewayAccount = finalGatewayConfig.channels.matrix.accounts["cli-setup-gateway"];
5913+expect(finalGatewayAccount?.encryption).toBe(true);
5914+expect(finalGatewayAccount?.setupBootstrapMarker).toBe("preserved");
5913591559145916expect(runMatrixQaOpenClawCli.mock.calls.map(([params]) => params.args)).toEqual([
59155917["matrix", "encryption", "setup", "--account", "cli-setup-gateway", "--json"],
59165918]);
5917-expect(registerWithToken).toHaveBeenCalledWith(
5918-expect.objectContaining({
5919-deviceName: "OpenClaw Matrix QA CLI Setup Gateway",
5920-registrationToken: "registration-token",
5921-}),
5922-);
5923-expect(registerWithToken).toHaveBeenCalledWith(
5924-expect.objectContaining({
5925-deviceName: "OpenClaw Matrix QA CLI Setup Driver",
5926-registrationToken: "registration-token",
5927-}),
5928-);
5919+const registrationRequests = registerWithToken.mock.calls.map(([request]) => request);
5920+expect(
5921+registrationRequests.some(
5922+(request) =>
5923+request.deviceName === "OpenClaw Matrix QA CLI Setup Gateway" &&
5924+request.registrationToken === "registration-token",
5925+),
5926+).toBe(true);
5927+expect(
5928+registrationRequests.some(
5929+(request) =>
5930+request.deviceName === "OpenClaw Matrix QA CLI Setup Driver" &&
5931+request.registrationToken === "registration-token",
5932+),
5933+).toBe(true);
59295934expect(createPrivateRoom).toHaveBeenCalledWith({
59305935encrypted: true,
59315936inviteUserIds: ["@cli-gateway:matrix-qa.test"],
@@ -5934,24 +5939,18 @@ describe("matrix live qa scenarios", () => {
59345939expect(joinRoom).toHaveBeenCalledWith("!isolated-e2ee:matrix-qa.test");
59355940expect(patchGatewayConfig).not.toHaveBeenCalled();
59365941expect(restartGatewayAfterStateMutation).toHaveBeenCalledTimes(2);
5937-expect(driverClient.sendTextMessage).toHaveBeenCalledWith(
5938-expect.objectContaining({
5939-mentionUserIds: ["@cli-gateway:matrix-qa.test"],
5940-roomId: "!isolated-e2ee:matrix-qa.test",
5941-}),
5942-);
5942+const driverMessage = driverClient.sendTextMessage.mock.calls[0]?.[0];
5943+expect(driverMessage?.mentionUserIds).toEqual(["@cli-gateway:matrix-qa.test"]);
5944+expect(driverMessage?.roomId).toBe("!isolated-e2ee:matrix-qa.test");
59435945expect(driverClient.waitForJoinedMember).toHaveBeenCalledWith({
59445946roomId: "!isolated-e2ee:matrix-qa.test",
59455947timeoutMs: 8_000,
59465948userId: "@cli-gateway:matrix-qa.test",
59475949});
5948-expect(createMatrixQaE2eeScenarioClient).toHaveBeenCalledWith(
5949-expect.objectContaining({
5950-accessToken: "cli-driver-token",
5951-deviceId: "CLIDRIVERDEVICE",
5952-userId: "@cli-driver:matrix-qa.test",
5953-}),
5954-);
5950+const e2eeClientOptions = createMatrixQaE2eeScenarioClient.mock.calls[0]?.[0];
5951+expect(e2eeClientOptions?.accessToken).toBe("cli-driver-token");
5952+expect(e2eeClientOptions?.deviceId).toBe("CLIDRIVERDEVICE");
5953+expect(e2eeClientOptions?.userId).toBe("@cli-driver:matrix-qa.test");
59555954expect(waitGatewayAccountReady).toHaveBeenCalledWith("cli-setup-gateway", {
59565955timeoutMs: 8_000,
59575956});
@@ -6008,52 +6007,54 @@ describe("matrix live qa scenarios", () => {
6008600760096008const scenario = requireMatrixQaScenario("matrix-e2ee-key-bootstrap-failure");
601060096011-await expect(
6012-runMatrixQaScenario(scenario, {
6013-baseUrl: "http://127.0.0.1:28008/",
6014-canary: undefined,
6015-driverAccessToken: "driver-token",
6016-driverDeviceId: "DRIVERDEVICE",
6017-driverUserId: "@driver:matrix-qa.test",
6018-observedEvents: [],
6019-observerAccessToken: "observer-token",
6020-observerUserId: "@observer:matrix-qa.test",
6021-outputDir: "/tmp/matrix-qa",
6022-roomId: "!main:matrix-qa.test",
6023-restartGateway: undefined,
6024-syncState: {},
6025-sutAccessToken: "sut-token",
6026-sutUserId: "@sut:matrix-qa.test",
6027-timeoutMs: 8_000,
6028-topology: {
6029-defaultRoomId: "!main:matrix-qa.test",
6030-defaultRoomKey: "main",
6031-rooms: [
6032-{
6033-key: matrixQaE2eeRoomKey("matrix-e2ee-key-bootstrap-failure"),
6034-kind: "group",
6035-memberRoles: ["driver", "observer", "sut"],
6036-memberUserIds: [
6037-"@driver:matrix-qa.test",
6038-"@observer:matrix-qa.test",
6039-"@sut:matrix-qa.test",
6040-],
6041-name: "E2EE",
6042-requireMention: true,
6043-roomId: "!e2ee:matrix-qa.test",
6044-},
6045-],
6046-},
6047-}),
6048-).resolves.toMatchObject({
6049-artifacts: {
6050-bootstrapActor: "driver",
6051-bootstrapSuccess: false,
6052-faultedEndpoint: "/_matrix/client/v3/room_keys/version",
6053-faultHitCount: 1,
6054-faultRuleId: "room-key-backup-version-unavailable",
6010+const result = await runMatrixQaScenario(scenario, {
6011+baseUrl: "http://127.0.0.1:28008/",
6012+canary: undefined,
6013+driverAccessToken: "driver-token",
6014+driverDeviceId: "DRIVERDEVICE",
6015+driverUserId: "@driver:matrix-qa.test",
6016+observedEvents: [],
6017+observerAccessToken: "observer-token",
6018+observerUserId: "@observer:matrix-qa.test",
6019+outputDir: "/tmp/matrix-qa",
6020+roomId: "!main:matrix-qa.test",
6021+restartGateway: undefined,
6022+syncState: {},
6023+sutAccessToken: "sut-token",
6024+sutUserId: "@sut:matrix-qa.test",
6025+timeoutMs: 8_000,
6026+topology: {
6027+defaultRoomId: "!main:matrix-qa.test",
6028+defaultRoomKey: "main",
6029+rooms: [
6030+{
6031+key: matrixQaE2eeRoomKey("matrix-e2ee-key-bootstrap-failure"),
6032+kind: "group",
6033+memberRoles: ["driver", "observer", "sut"],
6034+memberUserIds: [
6035+"@driver:matrix-qa.test",
6036+"@observer:matrix-qa.test",
6037+"@sut:matrix-qa.test",
6038+],
6039+name: "E2EE",
6040+requireMention: true,
6041+roomId: "!e2ee:matrix-qa.test",
6042+},
6043+],
60556044},
60566045});
6046+const artifacts = result.artifacts as {
6047+bootstrapActor?: unknown;
6048+bootstrapSuccess?: unknown;
6049+faultedEndpoint?: unknown;
6050+faultHitCount?: unknown;
6051+faultRuleId?: unknown;
6052+};
6053+expect(artifacts.bootstrapActor).toBe("driver");
6054+expect(artifacts.bootstrapSuccess).toBe(false);
6055+expect(artifacts.faultedEndpoint).toBe("/_matrix/client/v3/room_keys/version");
6056+expect(artifacts.faultHitCount).toBe(1);
6057+expect(artifacts.faultRuleId).toBe("room-key-backup-version-unavailable");
6057605860586059const proxyArgs = startMatrixQaFaultProxy.mock.calls[0]?.[0];
60596060if (!proxyArgs) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。