Skip to content

Commit 96b2144

Browse files
committed
cleanup
1 parent 00bcf09 commit 96b2144

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';
@@ -557,20 +556,13 @@ describe('KeyringController', () => {
557556
await withController(
558557
{ cacheEncryptionKey },
559558
async ({ controller, initialState }) => {
560-
// const initialVault = controller.state.vault;
561559
const initialKeyrings = controller.state.keyrings;
562560
await controller.createNewVaultAndRestore(
563561
password,
564562
uint8ArraySeed,
565563
);
566564
expect(controller.state).not.toBe(initialState);
567565
expect(controller.state.vault).toBeDefined();
568-
// TODO
569-
// This test is nonsensical!? Why would a new vault be identical
570-
// to the first one? (Considering that the initial seed phrase is
571-
// randomly generated.) This only worked before because the
572-
// encryptor returned a constant value.
573-
// expect(controller.state.vault).toStrictEqual(initialVault);
574566
expect(controller.state.keyrings).toHaveLength(
575567
initialKeyrings.length,
576568
);
@@ -599,7 +591,8 @@ describe('KeyringController', () => {
599591
currentSeedWord,
600592
);
601593

602-
expect(encryptSpy).toHaveBeenCalledWith(expect.any(Object), [
594+
const key = JSON.parse(MOCK_ENCRYPTION_KEY);
595+
expect(encryptSpy).toHaveBeenCalledWith(key, [
603596
{
604597
data: serializedKeyring,
605598
type: 'HD Key Tree',
@@ -646,10 +639,6 @@ describe('KeyringController', () => {
646639
await withController(
647640
{ cacheEncryptionKey },
648641
async ({ controller }) => {
649-
// await controller.createNewVaultAndRestore(
650-
// password,
651-
// uint8ArraySeed,
652-
// );
653642
expect(controller.state.encryptionKey).toBeDefined();
654643
expect(controller.state.encryptionSalt).toBeDefined();
655644
},
@@ -2702,8 +2691,6 @@ describe('KeyringController', () => {
27022691
await withController(
27032692
{
27042693
cacheEncryptionKey,
2705-
// skipVaultCreation: true,
2706-
// state: { vault: 'my vault' },
27072694
},
27082695
async ({ controller, encryptor }) => {
27092696
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2724,8 +2711,6 @@ describe('KeyringController', () => {
27242711
await withController(
27252712
{
27262713
cacheEncryptionKey,
2727-
// skipVaultCreation: true,
2728-
// state: { vault: 'my vault' },
27292714
},
27302715
async ({ controller, encryptor }) => {
27312716
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2758,8 +2743,6 @@ describe('KeyringController', () => {
27582743
await withController(
27592744
{
27602745
cacheEncryptionKey,
2761-
// state: { vault: 'my vault' },
2762-
// skipVaultCreation: true,
27632746
},
27642747
async ({ controller, encryptor }) => {
27652748
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2800,10 +2783,6 @@ describe('KeyringController', () => {
28002783
await withController(
28012784
{
28022785
cacheEncryptionKey: true,
2803-
// state: {
2804-
// vault: 'my vault',
2805-
// },
2806-
// skipVaultCreation: true,
28072786
},
28082787
async ({ controller, encryptor }) => {
28092788
const encryptWithKeySpy = jest.spyOn(
@@ -2863,10 +2842,6 @@ describe('KeyringController', () => {
28632842
await withController(
28642843
{
28652844
cacheEncryptionKey: false,
2866-
state: {
2867-
vault: 'my vault',
2868-
},
2869-
skipVaultCreation: true,
28702845
},
28712846
async ({ controller, encryptor }) => {
28722847
const encryptSpy = jest.spyOn(encryptor, 'encrypt');
@@ -2917,9 +2892,7 @@ describe('KeyringController', () => {
29172892
stubKeyringClassWithAccount(HdKeyring, '0x123');
29182893
await withController(
29192894
{
2920-
// skipVaultCreation: true,
29212895
cacheEncryptionKey,
2922-
// state: { vault: 'my vault' },
29232896
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29242897
},
29252898
async ({ controller, encryptor, messenger }) => {
@@ -2948,9 +2921,7 @@ describe('KeyringController', () => {
29482921
it('should unlock the wallet also if encryption parameters are outdated and the vault upgrade fails', async () => {
29492922
await withController(
29502923
{
2951-
// skipVaultCreation: true,
29522924
cacheEncryptionKey,
2953-
// state: { vault: 'my vault' },
29542925
},
29552926
async ({ controller, encryptor }) => {
29562927
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -2977,9 +2948,7 @@ describe('KeyringController', () => {
29772948
stubKeyringClassWithAccount(HdKeyring, '0x123');
29782949
await withController(
29792950
{
2980-
// skipVaultCreation: true,
29812951
cacheEncryptionKey,
2982-
// state: { vault: 'my vault' },
29832952
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29842953
},
29852954
async ({ controller, encryptor, messenger }) => {
@@ -3008,9 +2977,7 @@ describe('KeyringController', () => {
30082977
it('should upgrade the vault encryption if the key encryptor has different parameters', async () => {
30092978
await withController(
30102979
{
3011-
// skipVaultCreation: true,
30122980
cacheEncryptionKey,
3013-
// state: { vault: 'my vault' },
30142981
},
30152982
async ({ controller, encryptor }) => {
30162983
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3035,9 +3002,7 @@ describe('KeyringController', () => {
30353002
it('should not upgrade the vault encryption if the key encryptor has the same parameters', async () => {
30363003
await withController(
30373004
{
3038-
// skipVaultCreation: true,
30393005
cacheEncryptionKey,
3040-
// state: { vault: 'my vault' },
30413006
},
30423007
async ({ controller, encryptor }) => {
30433008
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3066,9 +3031,7 @@ describe('KeyringController', () => {
30663031
it('should upgrade the vault encryption if the generic encryptor has different parameters', async () => {
30673032
await withController(
30683033
{
3069-
skipVaultCreation: true,
30703034
cacheEncryptionKey,
3071-
state: { vault: 'my vault' },
30723035
},
30733036
async ({ controller, encryptor }) => {
30743037
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3092,9 +3055,7 @@ describe('KeyringController', () => {
30923055
it('should not upgrade the vault encryption if the encryptor has the same parameters and the keyring has metadata', async () => {
30933056
await withController(
30943057
{
3095-
// skipVaultCreation: true,
30963058
cacheEncryptionKey,
3097-
// state: { vault: 'my vault' },
30983059
},
30993060
async ({ controller, encryptor }) => {
31003061
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3147,9 +3108,7 @@ describe('KeyringController', () => {
31473108
it('should throw error when using the wrong password', async () => {
31483109
await withController(
31493110
{
3150-
// skipVaultCreation: true,
31513111
cacheEncryptionKey,
3152-
// state: { vault: 'my vault' },
31533112
},
31543113
async ({ controller }) => {
31553114
await expect(
@@ -3180,13 +3139,6 @@ describe('KeyringController', () => {
31803139
await withController(
31813140
{
31823141
cacheEncryptionKey: true,
3183-
// skipVaultCreation: true,
3184-
// state: {
3185-
// vault: JSON.stringify({ data: '0x123', salt: 'my salt' }),
3186-
// // @ts-expect-error we want to force the controller to have an
3187-
// // encryption salt equal to the one in the vault
3188-
// encryptionSalt: 'my salt',
3189-
// },
31903142
},
31913143
async ({ controller, initialState, encryptor }) => {
31923144
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -3214,13 +3166,6 @@ describe('KeyringController', () => {
32143166
await withController(
32153167
{
32163168
cacheEncryptionKey: true,
3217-
// skipVaultCreation: true,
3218-
// state: {
3219-
// vault: JSON.stringify({ data: '0x123', salt: 'my salt' }),
3220-
// // @ts-expect-error we want to force the controller to have an
3221-
// // encryption salt equal to the one in the vault
3222-
// encryptionSalt: 'my salt',
3223-
// },
32243169
},
32253170
async ({ controller, initialState, encryptor }) => {
32263171
const encryptWithKeySpy = jest.spyOn(encryptor, 'encryptWithKey');

0 commit comments

Comments
 (0)