Skip to content

Commit b863dd5

Browse files
committed
add test case for failure during vault upgrade
1 parent 9716cde commit b863dd5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,32 @@ describe('KeyringController', () => {
29232923
);
29242924
});
29252925

2926+
it('should unlock the wallet also if encryption parameters are outdated the vault upgrade fails', async () => {
2927+
await withController(
2928+
{
2929+
skipVaultCreation: true,
2930+
cacheEncryptionKey,
2931+
state: { vault: 'my vault' },
2932+
},
2933+
async ({ controller, encryptor }) => {
2934+
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
2935+
jest.spyOn(encryptor, 'encrypt').mockRejectedValue(new Error());
2936+
jest.spyOn(encryptor, 'decrypt').mockResolvedValueOnce([
2937+
{
2938+
type: KeyringTypes.hd,
2939+
data: {
2940+
accounts: ['0x123'],
2941+
},
2942+
},
2943+
]);
2944+
2945+
await controller.submitPassword(password);
2946+
2947+
expect(controller.state.isUnlocked).toBe(true);
2948+
},
2949+
);
2950+
});
2951+
29262952
it('should unlock the wallet discarding existing duplicate accounts', async () => {
29272953
stubKeyringClassWithAccount(MockKeyring, '0x123');
29282954
// @ts-expect-error HdKeyring is not yet compatible with Keyring type.

0 commit comments

Comments
 (0)