Skip to content

Commit

Permalink
chore(multi-srp): review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykLucka committed Feb 17, 2025
1 parent 7a6b427 commit a0a1422
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion eslint-warning-thresholds.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"n/no-unsupported-features/node-builtins": 1
},
"packages/keyring-controller/src/KeyringController.test.ts": {
"import-x/namespace": 15,
"import-x/namespace": 14,
"jest/no-conditional-in-test": 8
},
"packages/keyring-controller/src/KeyringController.ts": {
Expand Down
24 changes: 5 additions & 19 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('KeyringController', () => {
]);
await controller.submitPassword(password);
await expect(controller.addNewAccount()).rejects.toThrow(
'KeyringController - keyring metadata length mismatch',
KeyringControllerError.KeyringMetadataLengthMismatch,
);
},
);
Expand Down Expand Up @@ -782,9 +782,9 @@ describe('KeyringController', () => {
describe('when wrong password is provided', () => {
it('should export seed phrase', async () => {
await withController(async ({ controller, encryptor }) => {
sinon
.stub(encryptor, 'decrypt')
.throws(new Error('Invalid password'));
jest
.spyOn(encryptor, 'decrypt')
.mockRejectedValueOnce(new Error('Invalid password'));
await expect(controller.exportSeedPhrase('')).rejects.toThrow(
'Invalid password',
);
Expand Down Expand Up @@ -858,20 +858,6 @@ describe('KeyringController', () => {
);
});
});

it('should throw invalid password error with valid keyringId', async () => {
await withController(
async ({ controller, encryptor, initialState }) => {
const keyringId = initialState.keyringsMetadata[0].id;
jest
.spyOn(encryptor, 'decrypt')
.mockRejectedValueOnce(new Error('Invalid password'));
await expect(
controller.exportSeedPhrase('', keyringId),
).rejects.toThrow('Invalid password');
},
);
});
});
});
describe('when the keyring for the given address does not support exportAccount', () => {
Expand Down Expand Up @@ -2707,7 +2693,7 @@ describe('KeyringController', () => {
);
});

it('should throw unspported seed phrase error when keyring is not HD', async () => {
it('should throw unsupported seed phrase error when keyring is not HD', async () => {
await withController(async ({ controller }) => {
await controller.addNewKeyring(KeyringTypes.simple, [privateKey]);

Expand Down
4 changes: 2 additions & 2 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2309,11 +2309,11 @@ export class KeyringController extends BaseController<
async #newKeyring(type: string, data?: unknown): Promise<EthKeyring<Json>> {
const keyring = await this.#createKeyring(type, data);

this.#keyrings.push(keyring);
this.#keyringsMetadata.push(getDefaultKeyringMetadata());
if (this.#keyrings.length !== this.#keyringsMetadata.length) {
throw new Error('Keyring metadata missing');
}
this.#keyrings.push(keyring);
this.#keyringsMetadata.push(getDefaultKeyringMetadata());

return keyring;
}
Expand Down

0 comments on commit a0a1422

Please sign in to comment.