Skip to content

Commit 0516b30

Browse files
committed
cleanup
1 parent 426ebe7 commit 0516b30

File tree

1 file changed

+2
-57
lines changed

1 file changed

+2
-57
lines changed

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

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
import MockEncryptor, {
4040
DECRYPTION_ERROR,
4141
MOCK_ENCRYPTION_KEY,
42-
PASSWORD,
4342
} from '../tests/mocks/mockEncryptor';
4443
import { MockErc4337Keyring } from '../tests/mocks/mockErc4337Keyring';
4544
import { MockKeyring } from '../tests/mocks/mockKeyring';
@@ -555,20 +554,13 @@ describe('KeyringController', () => {
555554
await withController(
556555
{ cacheEncryptionKey },
557556
async ({ controller, initialState }) => {
558-
// const initialVault = controller.state.vault;
559557
const initialKeyrings = controller.state.keyrings;
560558
await controller.createNewVaultAndRestore(
561559
password,
562560
uint8ArraySeed,
563561
);
564562
expect(controller.state).not.toBe(initialState);
565563
expect(controller.state.vault).toBeDefined();
566-
// TODO
567-
// This test is nonsensical!? Why would a new vault be identical
568-
// to the first one? (Considering that the initial seed phrase is
569-
// randomly generated.) This only worked before because the
570-
// encryptor returned a constant value.
571-
// expect(controller.state.vault).toStrictEqual(initialVault);
572564
expect(controller.state.keyrings).toHaveLength(
573565
initialKeyrings.length,
574566
);
@@ -597,7 +589,8 @@ describe('KeyringController', () => {
597589
currentSeedWord,
598590
);
599591

600-
expect(encryptSpy).toHaveBeenCalledWith(expect.any(Object), [
592+
const key = JSON.parse(MOCK_ENCRYPTION_KEY);
593+
expect(encryptSpy).toHaveBeenCalledWith(key, [
601594
{
602595
data: serializedKeyring,
603596
type: 'HD Key Tree',
@@ -644,10 +637,6 @@ describe('KeyringController', () => {
644637
await withController(
645638
{ cacheEncryptionKey },
646639
async ({ controller }) => {
647-
// await controller.createNewVaultAndRestore(
648-
// password,
649-
// uint8ArraySeed,
650-
// );
651640
expect(controller.state.encryptionKey).toBeDefined();
652641
expect(controller.state.encryptionSalt).toBeDefined();
653642
},
@@ -2700,8 +2689,6 @@ describe('KeyringController', () => {
27002689
await withController(
27012690
{
27022691
cacheEncryptionKey,
2703-
// skipVaultCreation: true,
2704-
// state: { vault: 'my vault' },
27052692
},
27062693
async ({ controller, encryptor }) => {
27072694
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2722,8 +2709,6 @@ describe('KeyringController', () => {
27222709
await withController(
27232710
{
27242711
cacheEncryptionKey,
2725-
// skipVaultCreation: true,
2726-
// state: { vault: 'my vault' },
27272712
},
27282713
async ({ controller, encryptor }) => {
27292714
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2756,8 +2741,6 @@ describe('KeyringController', () => {
27562741
await withController(
27572742
{
27582743
cacheEncryptionKey,
2759-
// state: { vault: 'my vault' },
2760-
// skipVaultCreation: true,
27612744
},
27622745
async ({ controller, encryptor }) => {
27632746
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2798,10 +2781,6 @@ describe('KeyringController', () => {
27982781
await withController(
27992782
{
28002783
cacheEncryptionKey: true,
2801-
// state: {
2802-
// vault: 'my vault',
2803-
// },
2804-
// skipVaultCreation: true,
28052784
},
28062785
async ({ controller, encryptor }) => {
28072786
const encryptWithKeySpy = jest.spyOn(
@@ -2861,10 +2840,6 @@ describe('KeyringController', () => {
28612840
await withController(
28622841
{
28632842
cacheEncryptionKey: false,
2864-
state: {
2865-
vault: 'my vault',
2866-
},
2867-
skipVaultCreation: true,
28682843
},
28692844
async ({ controller, encryptor }) => {
28702845
const encryptSpy = jest.spyOn(encryptor, 'encrypt');
@@ -2915,9 +2890,7 @@ describe('KeyringController', () => {
29152890
stubKeyringClassWithAccount(HdKeyring, '0x123');
29162891
await withController(
29172892
{
2918-
// skipVaultCreation: true,
29192893
cacheEncryptionKey,
2920-
// state: { vault: 'my vault' },
29212894
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29222895
},
29232896
async ({ controller, encryptor, messenger }) => {
@@ -2946,9 +2919,7 @@ describe('KeyringController', () => {
29462919
it('should unlock the wallet also if encryption parameters are outdated and the vault upgrade fails', async () => {
29472920
await withController(
29482921
{
2949-
// skipVaultCreation: true,
29502922
cacheEncryptionKey,
2951-
// state: { vault: 'my vault' },
29522923
},
29532924
async ({ controller, encryptor }) => {
29542925
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -2975,9 +2946,7 @@ describe('KeyringController', () => {
29752946
stubKeyringClassWithAccount(HdKeyring, '0x123');
29762947
await withController(
29772948
{
2978-
// skipVaultCreation: true,
29792949
cacheEncryptionKey,
2980-
// state: { vault: 'my vault' },
29812950
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29822951
},
29832952
async ({ controller, encryptor, messenger }) => {
@@ -3006,9 +2975,7 @@ describe('KeyringController', () => {
30062975
it('should upgrade the vault encryption if the key encryptor has different parameters', async () => {
30072976
await withController(
30082977
{
3009-
// skipVaultCreation: true,
30102978
cacheEncryptionKey,
3011-
// state: { vault: 'my vault' },
30122979
},
30132980
async ({ controller, encryptor }) => {
30142981
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3033,9 +3000,7 @@ describe('KeyringController', () => {
30333000
it('should not upgrade the vault encryption if the key encryptor has the same parameters', async () => {
30343001
await withController(
30353002
{
3036-
// skipVaultCreation: true,
30373003
cacheEncryptionKey,
3038-
// state: { vault: 'my vault' },
30393004
},
30403005
async ({ controller, encryptor }) => {
30413006
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3064,9 +3029,7 @@ describe('KeyringController', () => {
30643029
it('should upgrade the vault encryption if the generic encryptor has different parameters', async () => {
30653030
await withController(
30663031
{
3067-
skipVaultCreation: true,
30683032
cacheEncryptionKey,
3069-
state: { vault: 'my vault' },
30703033
},
30713034
async ({ controller, encryptor }) => {
30723035
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3090,9 +3053,7 @@ describe('KeyringController', () => {
30903053
it('should not upgrade the vault encryption if the encryptor has the same parameters and the keyring has metadata', async () => {
30913054
await withController(
30923055
{
3093-
// skipVaultCreation: true,
30943056
cacheEncryptionKey,
3095-
// state: { vault: 'my vault' },
30963057
},
30973058
async ({ controller, encryptor }) => {
30983059
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3145,9 +3106,7 @@ describe('KeyringController', () => {
31453106
it('should throw error when using the wrong password', async () => {
31463107
await withController(
31473108
{
3148-
// skipVaultCreation: true,
31493109
cacheEncryptionKey,
3150-
// state: { vault: 'my vault' },
31513110
},
31523111
async ({ controller }) => {
31533112
await expect(
@@ -3178,13 +3137,6 @@ describe('KeyringController', () => {
31783137
await withController(
31793138
{
31803139
cacheEncryptionKey: true,
3181-
// skipVaultCreation: true,
3182-
// state: {
3183-
// vault: JSON.stringify({ data: '0x123', salt: 'my salt' }),
3184-
// // @ts-expect-error we want to force the controller to have an
3185-
// // encryption salt equal to the one in the vault
3186-
// encryptionSalt: 'my salt',
3187-
// },
31883140
},
31893141
async ({ controller, initialState, encryptor }) => {
31903142
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -3212,13 +3164,6 @@ describe('KeyringController', () => {
32123164
await withController(
32133165
{
32143166
cacheEncryptionKey: true,
3215-
// skipVaultCreation: true,
3216-
// state: {
3217-
// vault: JSON.stringify({ data: '0x123', salt: 'my salt' }),
3218-
// // @ts-expect-error we want to force the controller to have an
3219-
// // encryption salt equal to the one in the vault
3220-
// encryptionSalt: 'my salt',
3221-
// },
32223167
},
32233168
async ({ controller, initialState, encryptor }) => {
32243169
const encryptWithKeySpy = jest.spyOn(encryptor, 'encryptWithKey');

0 commit comments

Comments
 (0)