Skip to content

Commit

Permalink
test: add hdkeyring test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Jan 26, 2024
1 parent ea7d379 commit 7db3917
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/keyring-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 80.55,
functions: 98.93,
lines: 96.11,
statements: 96.14,
branches: 95.17,
functions: 100,
lines: 99.22,
statements: 99.22,
},
},

Expand Down
15 changes: 15 additions & 0 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TransactionFactory } from '@ethereumjs/tx';
import { CryptoHDKey, ETHSignature } from '@keystonehq/bc-ur-registry-eth';
import { MetaMaskKeyring as QRKeyring } from '@keystonehq/metamask-airgapped-keyring';
import { ControllerMessenger } from '@metamask/base-controller';
import HDKeyring from '@metamask/eth-hd-keyring';
import {
normalize,
recoverPersonalSignature,
Expand Down Expand Up @@ -525,6 +526,20 @@ describe('KeyringController', () => {
},
);
});

it('should throw error if the first account is not found on the keyring', async () => {
jest
.spyOn(HDKeyring.prototype, 'getAccounts')
.mockResolvedValue([]);
await withController(
{ skipVaultCreation: true },
async ({ controller }) => {
await expect(
controller.createNewVaultAndKeychain(password),
).rejects.toThrow(KeyringControllerError.NoFirstAccount);
},
);
});
});

describe('when there is an existing vault', () => {
Expand Down

0 comments on commit 7db3917

Please sign in to comment.