Skip to content

Commit fe3dec9

Browse files
committed
Avoid running all the tests twice
Currently all of these tests are running twice, with different client configurations. That's not really adding much value; we just need to run specific tests that way.
1 parent af84ef5 commit fe3dec9

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

spec/integ/crypto/verification.spec.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ const TEST_HOMESERVER_URL = "https://alice-server.com";
9999
*/
100100
// we test with both crypto stacks...
101101
describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: string, initCrypto: InitCrypto) => {
102-
// and with (1) the default verification method list, (2) a custom verification method list.
103-
describe.each([undefined, ["m.sas.v1", "m.qr_code.show.v1", "m.reciprocate.v1"]])(
104-
"supported methods=%s",
105-
(methods) => {
106-
runTests(backend, initCrypto, methods);
107-
},
108-
);
109-
});
110-
111-
function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | undefined) {
112102
// oldBackendOnly is an alternative to `it` or `test` which will skip the test if we are running against the
113103
// Rust backend. Once we have full support in the rust sdk, it will go away.
114104
const oldBackendOnly = backend === "rust-sdk" ? test.skip : test;
@@ -155,7 +145,9 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
155145
e2eKeyResponder.addDeviceKeys(TEST_USER_ID, TEST_DEVICE_ID, SIGNED_TEST_DEVICE_DATA);
156146
});
157147

158-
it("can verify another device via SAS", async () => {
148+
// test with (1) the default verification method list, (2) a custom verification method list.
149+
const TEST_METHODS = ["m.sas.v1", "m.qr_code.show.v1", "m.reciprocate.v1"];
150+
it.each([undefined, TEST_METHODS])("can verify via SAS (supported methods=%s)", async (methods) => {
159151
aliceClient = await startTestClient({ verificationMethods: methods });
160152
await waitForDeviceList();
161153

@@ -321,7 +313,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
321313
});
322314

323315
it("Can make a verification request to *all* devices", async () => {
324-
aliceClient = await startTestClient({ verificationMethods: methods });
316+
aliceClient = await startTestClient();
325317
// we need an existing cross-signing key for this
326318
e2eKeyResponder.addCrossSigningData(SIGNED_CROSS_SIGNING_KEYS_DATA);
327319
await waitForDeviceList();
@@ -351,7 +343,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
351343
});
352344

353345
oldBackendOnly("can verify another via QR code with an untrusted cross-signing key", async () => {
354-
aliceClient = await startTestClient({ verificationMethods: methods });
346+
aliceClient = await startTestClient();
355347
// QRCode fails if we don't yet have the cross-signing keys, so make sure we have them now.
356348
e2eKeyResponder.addCrossSigningData(SIGNED_CROSS_SIGNING_KEYS_DATA);
357349
await waitForDeviceList();
@@ -367,9 +359,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
367359
const toDeviceMessage = requestBody.messages[TEST_USER_ID][TEST_DEVICE_ID];
368360
expect(toDeviceMessage.methods).toContain("m.qr_code.show.v1");
369361
expect(toDeviceMessage.methods).toContain("m.reciprocate.v1");
370-
if (methods === undefined) {
371-
expect(toDeviceMessage.methods).toContain("m.qr_code.scan.v1");
372-
}
362+
expect(toDeviceMessage.methods).toContain("m.qr_code.scan.v1");
373363
expect(toDeviceMessage.from_device).toEqual(aliceClient.deviceId);
374364
expect(toDeviceMessage.transaction_id).toEqual(transactionId);
375365

@@ -443,7 +433,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
443433
});
444434

445435
it("can cancel during the SAS phase", async () => {
446-
aliceClient = await startTestClient({ verificationMethods: methods });
436+
aliceClient = await startTestClient();
447437
await waitForDeviceList();
448438

449439
// have alice initiate a verification. She should send a m.key.verification.request
@@ -511,7 +501,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
511501
});
512502

513503
oldBackendOnly("Incoming verification: can accept", async () => {
514-
aliceClient = await startTestClient({ verificationMethods: methods });
504+
aliceClient = await startTestClient();
515505
const TRANSACTION_ID = "abcd";
516506

517507
// Initiate the request by sending a to-device message
@@ -579,7 +569,7 @@ function runTests(backend: string, initCrypto: InitCrypto, methods: string[] | u
579569
ev.sender ??= TEST_USER_ID;
580570
syncResponder.sendOrQueueSyncResponse({ to_device: { events: [ev] } });
581571
}
582-
}
572+
});
583573

584574
/**
585575
* Wait for the client under test to send a to-device message of the given type.

0 commit comments

Comments
 (0)