From 30cc7d4f0f59566fd5989d79f94019b9a36817cc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 4 Dec 2019 23:31:20 +0000 Subject: [PATCH] Fix one of the crypto.spec.js failures Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- spec/unit/crypto.spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/unit/crypto.spec.js b/spec/unit/crypto.spec.js index 55acf8b04..3ec55a28f 100644 --- a/spec/unit/crypto.spec.js +++ b/spec/unit/crypto.spec.js @@ -11,6 +11,7 @@ import TestClient from '../TestClient'; import {MatrixEvent} from '../../lib/models/event'; import Room from '../../lib/models/room'; import olmlib from '../../lib/crypto/olmlib'; +import {sleep} from "../../src/utils"; const EventEmitter = require("events").EventEmitter; @@ -18,8 +19,6 @@ const sdk = require("../.."); const Olm = global.Olm; -jest.useFakeTimers(); - describe("Crypto", function() { if (!sdk.CRYPTO_ENABLED) { return; @@ -270,7 +269,8 @@ describe("Crypto", function() { await bobDecryptor.onRoomKeyEvent(ksEvent); await eventPromise; 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)) .toBeFalsy(); }, @@ -301,6 +301,8 @@ describe("Crypto", function() { }); it("uses a new txnid for re-requesting keys", async function() { + jest.useFakeTimers(); + const event = new MatrixEvent({ sender: "@bob:example.com", room_id: "!someroom",