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

Commit fe45b61

Browse files
committed
refactor: add test case
1 parent 2e64041 commit fe45b61

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/KeyringController.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,35 @@ describe('KeyringController', () => {
887887
});
888888
});
889889

890+
describe(`with cacheEncryptionKey = true and encryptionKey is set`, () => {
891+
it('should not update the vault', async () => {
892+
const mockEncryptor = new MockEncryptor();
893+
const keyringController = await initializeKeyringController({
894+
password: PASSWORD,
895+
constructorOptions: {
896+
cacheEncryptionKey: true,
897+
encryptor: mockEncryptor,
898+
},
899+
});
900+
const initialVault = keyringController.store.getState().vault;
901+
const updatedVaultMock =
902+
'{"vault": "updated_vault_detail", "salt": "salt"}';
903+
const mockEncryptionResult = {
904+
data: '0x1234',
905+
iv: 'an iv',
906+
};
907+
sinon.stub(mockEncryptor, 'updateVault').resolves(updatedVaultMock);
908+
sinon
909+
.stub(mockEncryptor, 'encryptWithKey')
910+
.resolves(mockEncryptionResult);
911+
912+
await keyringController.unlockKeyrings(PASSWORD);
913+
const updatedVault = keyringController.store.getState().vault;
914+
915+
expect(initialVault).not.toBe(updatedVault);
916+
});
917+
});
918+
890919
describe(`with cacheEncryptionKey = false`, () => {
891920
it('should update the vault', async () => {
892921
const mockEncryptor = new MockEncryptor();

0 commit comments

Comments
 (0)