Skip to content

Commit ac29ffb

Browse files
committed
add test cases
checking for edge case where encryption key is not set after calling `changePassword` with same password
1 parent 97f3959 commit ac29ffb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/keyring-controller/src/KeyringController.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,28 @@ describe('KeyringController', () => {
33053305
},
33063306
);
33073307
});
3308+
3309+
it('should export key after password change', async () => {
3310+
await withController(
3311+
{ cacheEncryptionKey: true },
3312+
async ({ controller }) => {
3313+
await controller.changePassword('new password');
3314+
const encryptionKey = await controller.exportEncryptionKey();
3315+
expect(encryptionKey).toBeDefined();
3316+
},
3317+
);
3318+
});
3319+
3320+
it('should export key after password change to the same password', async () => {
3321+
await withController(
3322+
{ cacheEncryptionKey: true },
3323+
async ({ controller }) => {
3324+
await controller.changePassword(password);
3325+
const encryptionKey = await controller.exportEncryptionKey();
3326+
expect(encryptionKey).toBeDefined();
3327+
},
3328+
);
3329+
});
33083330
});
33093331

33103332
describe('verifySeedPhrase', () => {

0 commit comments

Comments
 (0)