diff --git a/app/scripts/controllers/decrypt-message.test.ts b/app/scripts/controllers/decrypt-message.test.ts index c7e180b9c924..21235b30a94f 100644 --- a/app/scripts/controllers/decrypt-message.test.ts +++ b/app/scripts/controllers/decrypt-message.test.ts @@ -169,6 +169,20 @@ describe('DecryptMessageController', () => { expect(result).toBe(mockExtState); }); + it('should throw when decrypting invalid message', async () => { + const messageToDecrypt = { + ...messageMock, + data: '0x7b2022666f6f223a202262617222207d', + }; + decryptMessageManagerMock.approveMessage.mockResolvedValue( + messageToDecrypt, + ); + + expect( + decryptMessageController.decryptMessage(messageToDecrypt), + ).rejects.toThrow('Invalid encrypted data.'); + }); + it('should cancel decrypt request', async () => { const messageToDecrypt = { ...messageMock, @@ -211,6 +225,17 @@ describe('DecryptMessageController', () => { expect(result).toBe(mockExtState); }); + it('should throw when decrypting invalid message inline', async () => { + const messageToDecrypt = { + ...messageMock, + data: '0x7b2022666f6f223a202262617222207d', + }; + + expect( + decryptMessageController.decryptMessageInline(messageToDecrypt), + ).rejects.toThrow('Invalid encrypted data.'); + }); + it('should be able to cancel decrypt message', async () => { decryptMessageManagerMock.rejectMessage.mockResolvedValue(messageMock); getStateMock.mockReturnValue(mockExtState);