1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-09 10:22:46 +03:00

Element-R: silence log errors when viewing a decryption failure (#3821)

This commit is contained in:
Richard van der Hoff
2023-10-23 11:16:42 +01:00
committed by GitHub
parent 6e2ac03f7e
commit 12e479a93e
2 changed files with 21 additions and 1 deletions

View File

@@ -505,6 +505,26 @@ describe("RustCrypto", () => {
expect(olmMachine.getRoomEventEncryptionInfo).not.toHaveBeenCalled();
});
it("should handle decryption failures", async () => {
const event = mkEvent({
event: true,
type: "m.room.encrypted",
content: { algorithm: "fake_alg" },
room: "!room:id",
});
event.event.event_id = "$event:id";
const mockCryptoBackend = {
decryptEvent: () => {
throw new Error("UISI");
},
};
await event.attemptDecryption(mockCryptoBackend as unknown as CryptoBackend);
const res = await rustCrypto.getEncryptionInfoForEvent(event);
expect(res).toBe(null);
expect(olmMachine.getRoomEventEncryptionInfo).not.toHaveBeenCalled();
});
it("passes the event into the OlmMachine", async () => {
const encryptedEvent = await makeEncryptedEvent();
const res = await rustCrypto.getEncryptionInfoForEvent(encryptedEvent);