1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Fix one of the crypto.spec.js failures

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2019-12-04 23:31:20 +00:00
parent 4a47867e49
commit 30cc7d4f0f

View File

@@ -11,6 +11,7 @@ import TestClient from '../TestClient';
import {MatrixEvent} from '../../lib/models/event'; import {MatrixEvent} from '../../lib/models/event';
import Room from '../../lib/models/room'; import Room from '../../lib/models/room';
import olmlib from '../../lib/crypto/olmlib'; import olmlib from '../../lib/crypto/olmlib';
import {sleep} from "../../src/utils";
const EventEmitter = require("events").EventEmitter; const EventEmitter = require("events").EventEmitter;
@@ -18,8 +19,6 @@ const sdk = require("../..");
const Olm = global.Olm; const Olm = global.Olm;
jest.useFakeTimers();
describe("Crypto", function() { describe("Crypto", function() {
if (!sdk.CRYPTO_ENABLED) { if (!sdk.CRYPTO_ENABLED) {
return; return;
@@ -270,7 +269,8 @@ describe("Crypto", function() {
await bobDecryptor.onRoomKeyEvent(ksEvent); await bobDecryptor.onRoomKeyEvent(ksEvent);
await eventPromise; await eventPromise;
expect(events[0].getContent().msgtype).not.toBe("m.bad.encrypted"); expect(events[0].getContent().msgtype).not.toBe("m.bad.encrypted");
// the room key request should be gone since we've now decypted everything await sleep(1);
// the room key request should be gone since we've now decrypted everything
expect(await cryptoStore.getOutgoingRoomKeyRequest(roomKeyRequestBody)) expect(await cryptoStore.getOutgoingRoomKeyRequest(roomKeyRequestBody))
.toBeFalsy(); .toBeFalsy();
}, },
@@ -301,6 +301,8 @@ describe("Crypto", function() {
}); });
it("uses a new txnid for re-requesting keys", async function() { it("uses a new txnid for re-requesting keys", async function() {
jest.useFakeTimers();
const event = new MatrixEvent({ const event = new MatrixEvent({
sender: "@bob:example.com", sender: "@bob:example.com",
room_id: "!someroom", room_id: "!someroom",