From 76bb27d474bb18009378783b200dc13eea497603 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:34:19 +0000 Subject: [PATCH 1/7] Fix linter errors in utils.test.ts --- packages/message-manager/src/utils.test.ts | 112 ++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/packages/message-manager/src/utils.test.ts b/packages/message-manager/src/utils.test.ts index a85ff2e1a6..656842bdd7 100644 --- a/packages/message-manager/src/utils.test.ts +++ b/packages/message-manager/src/utils.test.ts @@ -15,7 +15,7 @@ describe('utils', () => { }); describe('validateSignMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => util.validateSignMessageData({ data: '0x879a05', @@ -25,7 +25,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateSignMessageData({ @@ -37,7 +37,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if from address type is invalid', () => { const from = 123; expect(() => util.validateSignMessageData({ @@ -49,7 +49,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if no data', () => { + it('throws if no data', () => { expect(() => util.validateSignMessageData({ data: '0x879a05', @@ -59,63 +59,63 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid tyoe data', () => { - expect(() => - util.validateSignMessageData({ - data: 123, - from: '0x3244e191f1b4903970224322180f1fbbc415696b', - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow('Invalid message "data": 123 must be a valid string.'); - }); + it('throws if data type is invalid', () => { + expect(() => + util.validateSignMessageData({ + data: 123, + from: '0x3244e191f1b4903970224322180f1fbbc415696b', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow('Invalid message "data": 123 must be a valid string.'); }); +}); - describe('validateTypedMessageDataV1', () => { - it('should throw if no from address legacy', () => { - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: undefined must be a valid string.`); - }); +describe('validateTypedMessageDataV1', () => { + it('throws if no from address legacy', () => { + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: undefined must be a valid string.`); + }); - it('should throw if invalid from address', () => { - const from = '3244e191f1b4903970224322180f1'; - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - from, - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); - }); + it('throws if invalid from address', () => { + const from = '3244e191f1b4903970224322180f1'; + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + from, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); + }); - it('should throw if invalid type from address', () => { - const from = 123; - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - from, - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); - }); + it('throws if from address type is invalid', () => { + const from = 123; + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + from, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); + }); - it('should throw if incorrect data', () => { - expect(() => - util.validateTypedSignMessageDataV1({ - data: '0x879a05', - from: '0x3244e191f1b4903970224322180f1fbbc415696b', - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow('Invalid message "data":'); - }); + it('throws if data is incorrect', () => { + expect(() => + util.validateTypedSignMessageDataV1({ + data: '0x879a05', + from: '0x3244e191f1b4903970224322180f1fbbc415696b', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow('Invalid message "data":'); + }); it('should throw if no data', () => { expect(() => From f3871410694aacb7ccea5fac1ae608e38ecc720a Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:35:34 +0000 Subject: [PATCH 2/7] Update test descriptions to active tense --- .../src/AbstractMessageManager.test.ts | 22 +++++++++---------- .../src/DecryptMessageManager.test.ts | 6 ++--- .../src/PersonalMessageManager.test.ts | 20 ++++++++--------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/message-manager/src/AbstractMessageManager.test.ts b/packages/message-manager/src/AbstractMessageManager.test.ts index da11beb542..8a15e7fbea 100644 --- a/packages/message-manager/src/AbstractMessageManager.test.ts +++ b/packages/message-manager/src/AbstractMessageManager.test.ts @@ -51,7 +51,7 @@ const messageIdMock = 'message-id-mocked'; const fromMock = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; describe('AbstractTestManager', () => { - it('should set default state', () => { + it('sets default state', () => { const controller = new AbstractTestManager(); expect(controller.state).toStrictEqual({ unapprovedMessages: {}, @@ -59,12 +59,12 @@ describe('AbstractTestManager', () => { }); }); - it('should set default config', () => { + it('sets default config', () => { const controller = new AbstractTestManager(); expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -88,7 +88,7 @@ describe('AbstractTestManager', () => { expect(message.type).toBe(messageType); }); - it('should get all messages', async () => { + it('gets all messages', async () => { const controller = new AbstractTestManager(); const message = { id: messageId, @@ -153,7 +153,7 @@ describe('AbstractTestManager', () => { expect(message.securityProviderResponse).toBe(securityProviderResponseMock); }); - it('should reject a message', async () => { + it('rejects a message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -173,7 +173,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('rejected'); }); - it('should sign a message', async () => { + it('signs a message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -219,7 +219,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('test-status'); }); - it('should set a status to inProgress', async () => { + it('sets a status to inProgress', async () => { const controller = new AbstractTestManager( undefined, undefined, @@ -244,7 +244,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('inProgress'); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessageData = [ { name: 'Message', @@ -293,7 +293,7 @@ describe('AbstractTestManager', () => { }); }); - it('should approve typed message', async () => { + it('approves typed message', async () => { const controller = new AbstractTestManager(); const firstMessage = { from: '0xfoO', data: typedMessage }; const version = 'V1'; @@ -318,7 +318,7 @@ describe('AbstractTestManager', () => { }); describe('setMessageStatus', () => { - it('should set the given message status', async () => { + it('sets the given message status', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -335,7 +335,7 @@ describe('AbstractTestManager', () => { expect(messageAfter?.status).toBe('newstatus'); }); - it('should throw an error if message is not found', () => { + it('throws an error if message is not found', () => { const controller = new AbstractTestManager(); expect(() => controller.setMessageStatus(messageId, 'newstatus')).toThrow( diff --git a/packages/message-manager/src/DecryptMessageManager.test.ts b/packages/message-manager/src/DecryptMessageManager.test.ts index 6d68212912..521c52e2c0 100644 --- a/packages/message-manager/src/DecryptMessageManager.test.ts +++ b/packages/message-manager/src/DecryptMessageManager.test.ts @@ -81,7 +81,7 @@ describe('DecryptMessageManager', () => { expect(await promise).toStrictEqual(rawSigMock); }); - it('rejects with an error when status is "rejected"', async () => { + it('rejects with an error if the status is "rejected"', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock, @@ -98,7 +98,7 @@ describe('DecryptMessageManager', () => { ); }); - it('rejects with an error when decryption errored', async () => { + it('rejects with an error if decryption errors', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock, @@ -115,7 +115,7 @@ describe('DecryptMessageManager', () => { ); }); - it('rejects with an error when unapproved finishes', async () => { + it('rejects with an error if unapproved message finishes', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock, diff --git a/packages/message-manager/src/PersonalMessageManager.test.ts b/packages/message-manager/src/PersonalMessageManager.test.ts index c7a082c848..df60ba1e47 100644 --- a/packages/message-manager/src/PersonalMessageManager.test.ts +++ b/packages/message-manager/src/PersonalMessageManager.test.ts @@ -31,18 +31,18 @@ describe('PersonalMessageManager', () => { detectSIWEMock.mockReturnValue(siweMockNotFound); }); - it('should set default state', () => { + it('sets default state', () => { expect(controller.state).toStrictEqual({ unapprovedMessages: {}, unapprovedMessagesCount: 0, }); }); - it('should set default config', () => { + it('sets default config', () => { expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const messageId = '1'; const from = '0x0123'; const messageData = '0x123'; @@ -71,7 +71,7 @@ describe('PersonalMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should add a valid unapproved message', async () => { + it('adds a valid unapproved message', async () => { const messageStatus = 'unapproved'; const messageType = 'personal_sign'; const messageParams = { @@ -102,7 +102,7 @@ describe('PersonalMessageManager', () => { expect(message.securityAlertResponse?.reason).toBe('reason'); }); - it('should throw when adding invalid message', async () => { + it('throws when adding invalid message', async () => { const from = 'foo'; const messageData = '0x123'; await expect( @@ -115,7 +115,7 @@ describe('PersonalMessageManager', () => { ); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessage = { id: '1', messageParams: { from: '0x1', data: '0x123' }, @@ -139,7 +139,7 @@ describe('PersonalMessageManager', () => { }); }); - it('should approve message', async () => { + it('approves message', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); const messageParams = await controller.approveMessage({ @@ -154,7 +154,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('approved'); }); - it('should set message status signed', async () => { + it('sets message status signed', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const rawSig = '0x5f7a0'; const messageId = await controller.addUnapprovedMessage(firstMessage); @@ -168,7 +168,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('signed'); }); - it('should reject message', async () => { + it('rejects message', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); controller.rejectMessage(messageId); @@ -179,7 +179,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('rejected'); }); - it('should add message including Ethereum sign in data', async () => { + it('adds message including Ethereum sign in data', async () => { detectSIWEMock.mockReturnValue(siweMockFound); const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); From 332832409796eba2249b558b6e9db7fe1d5baeb6 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:39:54 +0000 Subject: [PATCH 3/7] Update test descriptions to active tense in utils.test.ts --- packages/message-manager/src/utils.test.ts | 104 ++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/packages/message-manager/src/utils.test.ts b/packages/message-manager/src/utils.test.ts index 656842bdd7..55d29f4483 100644 --- a/packages/message-manager/src/utils.test.ts +++ b/packages/message-manager/src/utils.test.ts @@ -59,63 +59,63 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('throws if data type is invalid', () => { - expect(() => - util.validateSignMessageData({ - data: 123, - from: '0x3244e191f1b4903970224322180f1fbbc415696b', - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow('Invalid message "data": 123 must be a valid string.'); + it('throws if data type is invalid', () => { + expect(() => + util.validateSignMessageData({ + data: 123, + from: '0x3244e191f1b4903970224322180f1fbbc415696b', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow('Invalid message "data": 123 must be a valid string.'); + }); }); -}); -describe('validateTypedMessageDataV1', () => { - it('throws if no from address legacy', () => { - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: undefined must be a valid string.`); - }); + describe('validateTypedMessageDataV1', () => { + it('throws if no from address legacy', () => { + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: undefined must be a valid string.`); + }); - it('throws if invalid from address', () => { - const from = '3244e191f1b4903970224322180f1'; - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - from, - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); - }); + it('throws if invalid from address', () => { + const from = '3244e191f1b4903970224322180f1'; + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + from, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); + }); - it('throws if from address type is invalid', () => { - const from = 123; - expect(() => - util.validateTypedSignMessageDataV1({ - data: [], - from, - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); - }); + it('throws if from address type is invalid', () => { + const from = 123; + expect(() => + util.validateTypedSignMessageDataV1({ + data: [], + from, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); + }); - it('throws if data is incorrect', () => { - expect(() => - util.validateTypedSignMessageDataV1({ - data: '0x879a05', - from: '0x3244e191f1b4903970224322180f1fbbc415696b', - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any), - ).toThrow('Invalid message "data":'); - }); + it('throws if data is incorrect', () => { + expect(() => + util.validateTypedSignMessageDataV1({ + data: '0x879a05', + from: '0x3244e191f1b4903970224322180f1fbbc415696b', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any), + ).toThrow('Invalid message "data":'); + }); it('should throw if no data', () => { expect(() => From 9be61859cec8060a2b298ede1ed62a779db7bc7a Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:45:44 +0000 Subject: [PATCH 4/7] Refactor test descriptions to active tense in utils.test.ts --- packages/message-manager/src/utils.test.ts | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/message-manager/src/utils.test.ts b/packages/message-manager/src/utils.test.ts index 55d29f4483..e5029a6baf 100644 --- a/packages/message-manager/src/utils.test.ts +++ b/packages/message-manager/src/utils.test.ts @@ -117,7 +117,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no data', () => { + it('throws if no data', () => { expect(() => util.validateTypedSignMessageDataV1({ data: '0x879a05', @@ -128,7 +128,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if invalid type data', () => { + it('throws if invalid type data', () => { expect(() => util.validateTypedSignMessageDataV1({ data: [], @@ -144,7 +144,7 @@ describe('utils', () => { const dataTyped = '{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}'; const mockedCurrentChainId = toHex(1); - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -157,7 +157,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '3244e191f1b4903970224322180f1fb'; expect(() => util.validateTypedSignMessageDataV3V4( @@ -172,7 +172,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateTypedSignMessageDataV3V4( @@ -187,7 +187,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if array data', () => { + it('throws if array data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -201,7 +201,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no array data', () => { + it('throws if no array data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -214,7 +214,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no json valid data', () => { + it('throws if no json valid data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -228,7 +228,7 @@ describe('utils', () => { ).toThrow('Data must be passed as a valid JSON string.'); }); - it('should throw if current chain id is not present', () => { + it('throws if current chain id is not present', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -242,7 +242,7 @@ describe('utils', () => { ).toThrow('Current chainId cannot be null or undefined.'); }); - it('should throw if current chain id is not convertable to integer', () => { + it('throws if current chain id is not convertable to integer', () => { const unexpectedChainId = 'unexpected chain id'; expect(() => util.validateTypedSignMessageDataV3V4( @@ -264,7 +264,7 @@ describe('utils', () => { ); }); - it('should throw if current chain id is not matched with provided in message data', () => { + it('throws if current chain id is not matched with provided in message data', () => { const chainId = toHex(2); expect(() => util.validateTypedSignMessageDataV3V4( @@ -287,7 +287,7 @@ describe('utils', () => { ); }); - it('should throw if data not in typed message schema', () => { + it('throws if data not in typed message schema', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -301,7 +301,7 @@ describe('utils', () => { ).toThrow('Data must conform to EIP-712 schema.'); }); - it('should not throw if data is correct', () => { + it('does not throw if data is correct', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -315,7 +315,7 @@ describe('utils', () => { ).not.toThrow(); }); - it('should not throw if data is correct (object format)', () => { + it('does not throw if data is correct (object format)', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -331,7 +331,7 @@ describe('utils', () => { }); describe('validateEncryptionPublicKeyMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -339,7 +339,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateEncryptionPublicKeyMessageData({ @@ -350,7 +350,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateEncryptionPublicKeyMessageData({ @@ -361,7 +361,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should not throw if from address is correct', () => { + it('does not throw if from address is correct', () => { expect(() => util.validateEncryptionPublicKeyMessageData({ from: '0x3244e191f1b4903970224322180f1fbbc415696b', @@ -373,7 +373,7 @@ describe('utils', () => { }); describe('validateDecryptedMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any expect(() => util.validateDecryptedMessageData({} as any)).toThrow( @@ -381,7 +381,7 @@ describe('utils', () => { ); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateDecryptedMessageData({ @@ -392,7 +392,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateDecryptedMessageData({ @@ -403,7 +403,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should not throw if from address is correct', () => { + it('does not throw if from address is correct', () => { expect(() => util.validateDecryptedMessageData({ from: '0x3244e191f1b4903970224322180f1fbbc415696b', From 476ebb46fccf31437c52d100f47387bd4ed7dddf Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 01:07:08 +0000 Subject: [PATCH 5/7] Update test descriptions to active tense --- .../src/TypedMessageManager.test.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/message-manager/src/TypedMessageManager.test.ts b/packages/message-manager/src/TypedMessageManager.test.ts index 99539ce645..846ad25186 100644 --- a/packages/message-manager/src/TypedMessageManager.test.ts +++ b/packages/message-manager/src/TypedMessageManager.test.ts @@ -61,18 +61,18 @@ describe('TypedMessageManager', () => { ); }); - it('should set default state', () => { + it('sets default state', () => { expect(controller.state).toStrictEqual({ unapprovedMessages: {}, unapprovedMessagesCount: 0, }); }); - it('should set default config', () => { + it('sets default config', () => { expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const messageId = '1'; const from = '0x0123'; const messageTime = Date.now(); @@ -101,7 +101,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should throw when adding a valid unapproved message when getCurrentChainId is undefined', async () => { + it('throws when adding a valid unapproved message when getCurrentChainId is undefined', async () => { controller = new TypedMessageManager(); const version = 'V3'; const messageData = JSON.stringify(typedMessageV3V4); @@ -116,7 +116,7 @@ describe('TypedMessageManager', () => { ).rejects.toThrow('Current chainId cannot be null or undefined.'); }); - it('should add a valid unapproved message', async () => { + it('adds a valid unapproved message', async () => { const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; const version = 'version'; @@ -150,7 +150,7 @@ describe('TypedMessageManager', () => { expect(message.securityAlertResponse?.reason).toBe('reason'); }); - it('should add a valid V3 unapproved message as a JSON-parseable string', async () => { + it('adds a valid V3 unapproved message as a JSON-parseable string', async () => { getCurrentChainIdStub.mockImplementation(() => 1); const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; @@ -178,7 +178,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should add a valid V3 unapproved message as an object', async () => { + it('adds a valid V3 unapproved message as an object', async () => { getCurrentChainIdStub.mockImplementation(() => 1); const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; @@ -206,7 +206,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should throw when adding invalid legacy typed message', async () => { + it('throws when adding invalid legacy typed message', async () => { const from = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; const messageData = '0x879'; const version = 'V1'; @@ -222,7 +222,7 @@ describe('TypedMessageManager', () => { ).rejects.toThrow('Invalid message "data":'); }); - it('should throw when adding invalid typed message', async () => { + it('throws when adding invalid typed message', async () => { const mockGetChainId = jest.fn(); const from = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; const messageData = typedMessage; @@ -258,7 +258,7 @@ describe('TypedMessageManager', () => { expect(mockGetChainId).toHaveBeenCalled(); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessageData = [ { name: 'Message', @@ -306,7 +306,7 @@ describe('TypedMessageManager', () => { }); }); - it('should approve typed message', async () => { + it('approves typed message', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -330,7 +330,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('approved'); }); - it('should set message status signed', async () => { + it('sets message status signed', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -349,7 +349,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('signed'); }); - it('should reject message', async () => { + it('rejects message', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -366,7 +366,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('rejected'); }); - it('should set message status errored', async () => { + it('sets message status errored', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; From 78d6faa4b159b50b94e84c305f7385b6ad299e2b Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 07:29:05 +0000 Subject: [PATCH 6/7] Update AbstractMessageManager.test.ts descriptions to active tense --- packages/message-manager/src/AbstractMessageManager.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/message-manager/src/AbstractMessageManager.test.ts b/packages/message-manager/src/AbstractMessageManager.test.ts index 8a15e7fbea..5aadef1b8c 100644 --- a/packages/message-manager/src/AbstractMessageManager.test.ts +++ b/packages/message-manager/src/AbstractMessageManager.test.ts @@ -88,7 +88,7 @@ describe('AbstractTestManager', () => { expect(message.type).toBe(messageType); }); - it('gets all messages', async () => { + it('retrieves all messages', async () => { const controller = new AbstractTestManager(); const message = { id: messageId, @@ -370,7 +370,7 @@ describe('AbstractTestManager', () => { }); describe('setMetadata', () => { - it('should set the given message metadata', async () => { + it('sets the given message metadata', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -388,7 +388,7 @@ describe('AbstractTestManager', () => { expect(messageAfter?.metadata).toStrictEqual({ foo: 'bar' }); }); - it('should throw an error if message is not found', () => { + it('throws an error if message is not found', () => { const controller = new AbstractTestManager(); expect(() => controller.setMetadata(messageId, { foo: 'bar' })).toThrow( From 11ca9012df9e28804f7ce8dfc1e556e44ada5a00 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 07:36:37 +0000 Subject: [PATCH 7/7] Revert changes to DecryptMessageManager.test.ts --- packages/message-manager/src/DecryptMessageManager.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/message-manager/src/DecryptMessageManager.test.ts b/packages/message-manager/src/DecryptMessageManager.test.ts index 521c52e2c0..6d68212912 100644 --- a/packages/message-manager/src/DecryptMessageManager.test.ts +++ b/packages/message-manager/src/DecryptMessageManager.test.ts @@ -81,7 +81,7 @@ describe('DecryptMessageManager', () => { expect(await promise).toStrictEqual(rawSigMock); }); - it('rejects with an error if the status is "rejected"', async () => { + it('rejects with an error when status is "rejected"', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock, @@ -98,7 +98,7 @@ describe('DecryptMessageManager', () => { ); }); - it('rejects with an error if decryption errors', async () => { + it('rejects with an error when decryption errored', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock, @@ -115,7 +115,7 @@ describe('DecryptMessageManager', () => { ); }); - it('rejects with an error if unapproved message finishes', async () => { + it('rejects with an error when unapproved finishes', async () => { const promise = controller.addUnapprovedMessageAsync({ from: fromMock, data: dataMock,