From 7bb9bb7eb32cd2c76dfd6efaac97c756ec580263 Mon Sep 17 00:00:00 2001 From: Xiaoming Wang <7315988+dawnseeker8@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:06:07 +0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> --- src/ledger-keyring.test.ts | 15 +++++---------- src/ledger-keyring.ts | 2 +- src/ledger-transport-middleware.test.ts | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/ledger-keyring.test.ts b/src/ledger-keyring.test.ts index 956fe2d7..e26aeea0 100644 --- a/src/ledger-keyring.test.ts +++ b/src/ledger-keyring.test.ts @@ -230,27 +230,22 @@ describe('LedgerKeyring', function () { }); }); - it('throws errors when address is not found', async function () { + it('throws an error when the address is not found', async function () { const hdPath = `m/44'/60'/0'`; const account = '0x90A5b70d94418d6c25C19071e5b8170607f6302D'; - let thrownError; const accountIndexes: Record = {}; accountIndexes['0x90a'] = 1; - try { - await keyring.deserialize({ + await expect( + keyring.deserialize({ hdPath, accounts: [account], deviceId: 'some-device', implementFullBIP44: true, accountIndexes, - }); - } catch (error) { - thrownError = error; - } - expect(thrownError).toStrictEqual(new Error('Unknown address')); - }); + }), + ).rejects.toThrow('Unknown address'); }); describe('setDeviceId', function () { diff --git a/src/ledger-keyring.ts b/src/ledger-keyring.ts index 691b4d2a..727aa6da 100644 --- a/src/ledger-keyring.ts +++ b/src/ledger-keyring.ts @@ -22,7 +22,7 @@ const pathBase = 'm'; const hdPathString = `${pathBase}/44'/60'/0'`; const keyringType = 'Ledger Hardware'; -// This number make one of our failure test very slow which for loop need to run 1000 times. +// This number causes one of our failing tests to run very slowly, as the for loop needs to iterate 1000 times. const MAX_INDEX = 1000; enum NetworkApiUrls { diff --git a/src/ledger-transport-middleware.test.ts b/src/ledger-transport-middleware.test.ts index b0f05702..fafc79e2 100644 --- a/src/ledger-transport-middleware.test.ts +++ b/src/ledger-transport-middleware.test.ts @@ -63,7 +63,7 @@ describe('LedgerTransportMiddleware', function () { expect(app).toBeDefined(); }); - it('throw error when transport not set', async function () { + it('throws an error when the transport object is not set', async function () { transportMiddleware = new LedgerTransportMiddleware(); expect(() => transportMiddleware.getEthApp()).toThrow( 'Instance `transport` is not initialized.',