You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Merge remote-tracking branch 'origin/develop' into rav/async_crypto/1
This commit is contained in:
@@ -71,9 +71,13 @@ describe("MegolmDecryption", function() {
|
||||
groupSession = new global.Olm.OutboundGroupSession();
|
||||
groupSession.create();
|
||||
|
||||
const event = new MatrixEvent({});
|
||||
event.setClearData(
|
||||
{
|
||||
// construct a fake decrypted key event via the use of a mocked
|
||||
// 'crypto' implementation.
|
||||
const event = new MatrixEvent({
|
||||
type: 'm.room.encrypted',
|
||||
});
|
||||
const decryptedData = {
|
||||
clearEvent: {
|
||||
type: 'm.room_key',
|
||||
content: {
|
||||
algorithm: 'm.megolm.v1.aes-sha2',
|
||||
@@ -82,11 +86,19 @@ describe("MegolmDecryption", function() {
|
||||
session_key: groupSession.session_key(),
|
||||
},
|
||||
},
|
||||
"SENDER_CURVE25519",
|
||||
"SENDER_ED25519",
|
||||
);
|
||||
senderCurve25519Key: "SENDER_CURVE25519",
|
||||
claimedEd25519Key: "SENDER_ED25519",
|
||||
};
|
||||
|
||||
megolmDecryption.onRoomKeyEvent(event);
|
||||
const mockCrypto = {
|
||||
decryptEvent: function() {
|
||||
return Promise.resolve(decryptedData);
|
||||
},
|
||||
};
|
||||
|
||||
return event.attemptDecryption(mockCrypto).then(() => {
|
||||
megolmDecryption.onRoomKeyEvent(event);
|
||||
});
|
||||
});
|
||||
|
||||
it('can decrypt an event', function() {
|
||||
@@ -104,8 +116,8 @@ describe("MegolmDecryption", function() {
|
||||
},
|
||||
});
|
||||
|
||||
return megolmDecryption.decryptEvent(event).then(() => {
|
||||
expect(event.getContent()).toEqual('testytest');
|
||||
return megolmDecryption.decryptEvent(event).then((res) => {
|
||||
expect(res.clearEvent.content).toEqual('testytest');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user