Skip to content

Commit 721ff95

Browse files
committed
add tests
1 parent a36d3af commit 721ff95

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,36 @@ describe('KeyringController', () => {
32773277
});
32783278
});
32793279

3280+
describe('exportEncryptionKey', () => {
3281+
it('should export encryption key and unlock', async () => {
3282+
await withController(
3283+
{ cacheEncryptionKey: true },
3284+
async ({ controller }) => {
3285+
const encryptionKey = await controller.exportEncryptionKey();
3286+
expect(encryptionKey).toBeDefined();
3287+
3288+
await controller.setLocked();
3289+
3290+
await controller.submitEncryptionKey(encryptionKey);
3291+
3292+
expect(controller.isUnlocked()).toBe(true);
3293+
},
3294+
);
3295+
});
3296+
3297+
it('should throw error if controller is locked', async () => {
3298+
await withController(
3299+
{ cacheEncryptionKey: true },
3300+
async ({ controller }) => {
3301+
await controller.setLocked();
3302+
await expect(controller.exportEncryptionKey()).rejects.toThrow(
3303+
KeyringControllerError.EncryptionKeyNotSet,
3304+
);
3305+
},
3306+
);
3307+
});
3308+
});
3309+
32803310
describe('verifySeedPhrase', () => {
32813311
it('should return current seedphrase', async () => {
32823312
await withController(async ({ controller }) => {

0 commit comments

Comments
 (0)