You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
make algorithm.hasKeysForKeyRequest async
This commit is contained in:
@@ -119,29 +119,32 @@ describe("MegolmDecryption", function() {
|
||||
},
|
||||
};
|
||||
|
||||
expect(megolmDecryption.hasKeysForKeyRequest(keyRequest))
|
||||
.toBe(true);
|
||||
return megolmDecryption.hasKeysForKeyRequest(
|
||||
keyRequest,
|
||||
).then((hasKeys) => {
|
||||
expect(hasKeys).toBe(true);
|
||||
|
||||
// set up some pre-conditions for the share call
|
||||
const deviceInfo = {};
|
||||
mockCrypto.getStoredDevice.andReturn(deviceInfo);
|
||||
// set up some pre-conditions for the share call
|
||||
const deviceInfo = {};
|
||||
mockCrypto.getStoredDevice.andReturn(deviceInfo);
|
||||
|
||||
const awaitEnsureSessions = new Promise((res, rej) => {
|
||||
mockOlmLib.ensureOlmSessionsForDevices.andCall(() => {
|
||||
res();
|
||||
return Promise.resolve({'@alice:foo': {'alidevice': {
|
||||
sessionId: 'alisession',
|
||||
}}});
|
||||
const awaitEnsureSessions = new Promise((res, rej) => {
|
||||
mockOlmLib.ensureOlmSessionsForDevices.andCall(() => {
|
||||
res();
|
||||
return Promise.resolve({'@alice:foo': {'alidevice': {
|
||||
sessionId: 'alisession',
|
||||
}}});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
mockBaseApis.sendToDevice = expect.createSpy();
|
||||
mockBaseApis.sendToDevice = expect.createSpy();
|
||||
|
||||
// do the share
|
||||
megolmDecryption.shareKeysWithDevice(keyRequest);
|
||||
// do the share
|
||||
megolmDecryption.shareKeysWithDevice(keyRequest);
|
||||
|
||||
// it's asynchronous, so we have to wait a bit
|
||||
return awaitEnsureSessions.then(() => {
|
||||
// it's asynchronous, so we have to wait a bit
|
||||
return awaitEnsureSessions;
|
||||
}).then(() => {
|
||||
// check that it called encryptMessageForDevice with
|
||||
// appropriate args.
|
||||
expect(mockOlmLib.encryptMessageForDevice.calls.length)
|
||||
|
||||
Reference in New Issue
Block a user