Skip to content

Commit

Permalink
test: add cases for invalid encryption data
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Sep 18, 2023
1 parent 6cb3831 commit a31c0d8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/scripts/controllers/decrypt-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a31c0d8

Please sign in to comment.