Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit bc5716f

Browse files
authored
Ensure newly created vaults are unlocked (#155)
A new vault should be unlocked after being created, because the password is submitted as part of creating the vault. This was accidentally broken as part of #148. A unit test has been added to ensure this doesn't happen again.
1 parent 162a29f commit bc5716f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class KeyringController extends EventEmitter {
8080
async createNewVaultAndKeychain(password) {
8181
await this.createFirstKeyTree(password);
8282
await this.persistAllKeyrings(password);
83-
this.setUnlocked.bind();
83+
this.setUnlocked();
8484
this.fullUpdate();
8585
}
8686

test/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('KeyringController', function () {
8585
});
8686

8787
describe('createNewVaultAndKeychain', function () {
88-
it('should set a vault on the configManager', async function () {
88+
it('should create a new vault', async function () {
8989
keyringController.store.updateState({ vault: null });
9090
assert(!keyringController.store.getState().vault, 'no previous vault');
9191

@@ -95,6 +95,15 @@ describe('KeyringController', function () {
9595
expect(vault).toBeTruthy();
9696
});
9797

98+
it('should unlock the vault', async function () {
99+
keyringController.store.updateState({ vault: null });
100+
assert(!keyringController.store.getState().vault, 'no previous vault');
101+
102+
await keyringController.createNewVaultAndKeychain(password);
103+
const { isUnlocked } = keyringController.memStore.getState();
104+
expect(isUnlocked).toBe(true);
105+
});
106+
98107
it('should encrypt keyrings with the correct password each time they are persisted', async function () {
99108
keyringController.store.updateState({ vault: null });
100109
assert(!keyringController.store.getState().vault, 'no previous vault');

0 commit comments

Comments
 (0)