Skip to content

Commit 5b85b24

Browse files
committed
cleanup
1 parent 00bcf09 commit 5b85b24

File tree

1 file changed

+2
-56
lines changed

1 file changed

+2
-56
lines changed

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

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -557,20 +557,13 @@ describe('KeyringController', () => {
557557
await withController(
558558
{ cacheEncryptionKey },
559559
async ({ controller, initialState }) => {
560-
// const initialVault = controller.state.vault;
561560
const initialKeyrings = controller.state.keyrings;
562561
await controller.createNewVaultAndRestore(
563562
password,
564563
uint8ArraySeed,
565564
);
566565
expect(controller.state).not.toBe(initialState);
567566
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);
574567
expect(controller.state.keyrings).toHaveLength(
575568
initialKeyrings.length,
576569
);
@@ -599,7 +592,8 @@ describe('KeyringController', () => {
599592
currentSeedWord,
600593
);
601594

602-
expect(encryptSpy).toHaveBeenCalledWith(expect.any(Object), [
595+
const key = JSON.parse(MOCK_ENCRYPTION_KEY);
596+
expect(encryptSpy).toHaveBeenCalledWith(key, [
603597
{
604598
data: serializedKeyring,
605599
type: 'HD Key Tree',
@@ -646,10 +640,6 @@ describe('KeyringController', () => {
646640
await withController(
647641
{ cacheEncryptionKey },
648642
async ({ controller }) => {
649-
// await controller.createNewVaultAndRestore(
650-
// password,
651-
// uint8ArraySeed,
652-
// );
653643
expect(controller.state.encryptionKey).toBeDefined();
654644
expect(controller.state.encryptionSalt).toBeDefined();
655645
},
@@ -2702,8 +2692,6 @@ describe('KeyringController', () => {
27022692
await withController(
27032693
{
27042694
cacheEncryptionKey,
2705-
// skipVaultCreation: true,
2706-
// state: { vault: 'my vault' },
27072695
},
27082696
async ({ controller, encryptor }) => {
27092697
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2724,8 +2712,6 @@ describe('KeyringController', () => {
27242712
await withController(
27252713
{
27262714
cacheEncryptionKey,
2727-
// skipVaultCreation: true,
2728-
// state: { vault: 'my vault' },
27292715
},
27302716
async ({ controller, encryptor }) => {
27312717
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2758,8 +2744,6 @@ describe('KeyringController', () => {
27582744
await withController(
27592745
{
27602746
cacheEncryptionKey,
2761-
// state: { vault: 'my vault' },
2762-
// skipVaultCreation: true,
27632747
},
27642748
async ({ controller, encryptor }) => {
27652749
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -2800,10 +2784,6 @@ describe('KeyringController', () => {
28002784
await withController(
28012785
{
28022786
cacheEncryptionKey: true,
2803-
// state: {
2804-
// vault: 'my vault',
2805-
// },
2806-
// skipVaultCreation: true,
28072787
},
28082788
async ({ controller, encryptor }) => {
28092789
const encryptWithKeySpy = jest.spyOn(
@@ -2863,10 +2843,6 @@ describe('KeyringController', () => {
28632843
await withController(
28642844
{
28652845
cacheEncryptionKey: false,
2866-
state: {
2867-
vault: 'my vault',
2868-
},
2869-
skipVaultCreation: true,
28702846
},
28712847
async ({ controller, encryptor }) => {
28722848
const encryptSpy = jest.spyOn(encryptor, 'encrypt');
@@ -2917,9 +2893,7 @@ describe('KeyringController', () => {
29172893
stubKeyringClassWithAccount(HdKeyring, '0x123');
29182894
await withController(
29192895
{
2920-
// skipVaultCreation: true,
29212896
cacheEncryptionKey,
2922-
// state: { vault: 'my vault' },
29232897
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29242898
},
29252899
async ({ controller, encryptor, messenger }) => {
@@ -2948,9 +2922,7 @@ describe('KeyringController', () => {
29482922
it('should unlock the wallet also if encryption parameters are outdated and the vault upgrade fails', async () => {
29492923
await withController(
29502924
{
2951-
// skipVaultCreation: true,
29522925
cacheEncryptionKey,
2953-
// state: { vault: 'my vault' },
29542926
},
29552927
async ({ controller, encryptor }) => {
29562928
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -2977,9 +2949,7 @@ describe('KeyringController', () => {
29772949
stubKeyringClassWithAccount(HdKeyring, '0x123');
29782950
await withController(
29792951
{
2980-
// skipVaultCreation: true,
29812952
cacheEncryptionKey,
2982-
// state: { vault: 'my vault' },
29832953
keyringBuilders: [keyringBuilderFactory(MockKeyring)],
29842954
},
29852955
async ({ controller, encryptor, messenger }) => {
@@ -3008,9 +2978,7 @@ describe('KeyringController', () => {
30082978
it('should upgrade the vault encryption if the key encryptor has different parameters', async () => {
30092979
await withController(
30102980
{
3011-
// skipVaultCreation: true,
30122981
cacheEncryptionKey,
3013-
// state: { vault: 'my vault' },
30142982
},
30152983
async ({ controller, encryptor }) => {
30162984
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3035,9 +3003,7 @@ describe('KeyringController', () => {
30353003
it('should not upgrade the vault encryption if the key encryptor has the same parameters', async () => {
30363004
await withController(
30373005
{
3038-
// skipVaultCreation: true,
30393006
cacheEncryptionKey,
3040-
// state: { vault: 'my vault' },
30413007
},
30423008
async ({ controller, encryptor }) => {
30433009
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3066,9 +3032,7 @@ describe('KeyringController', () => {
30663032
it('should upgrade the vault encryption if the generic encryptor has different parameters', async () => {
30673033
await withController(
30683034
{
3069-
skipVaultCreation: true,
30703035
cacheEncryptionKey,
3071-
state: { vault: 'my vault' },
30723036
},
30733037
async ({ controller, encryptor }) => {
30743038
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(false);
@@ -3092,9 +3056,7 @@ describe('KeyringController', () => {
30923056
it('should not upgrade the vault encryption if the encryptor has the same parameters and the keyring has metadata', async () => {
30933057
await withController(
30943058
{
3095-
// skipVaultCreation: true,
30963059
cacheEncryptionKey,
3097-
// state: { vault: 'my vault' },
30983060
},
30993061
async ({ controller, encryptor }) => {
31003062
jest.spyOn(encryptor, 'isVaultUpdated').mockReturnValue(true);
@@ -3147,9 +3109,7 @@ describe('KeyringController', () => {
31473109
it('should throw error when using the wrong password', async () => {
31483110
await withController(
31493111
{
3150-
// skipVaultCreation: true,
31513112
cacheEncryptionKey,
3152-
// state: { vault: 'my vault' },
31533113
},
31543114
async ({ controller }) => {
31553115
await expect(
@@ -3180,13 +3140,6 @@ describe('KeyringController', () => {
31803140
await withController(
31813141
{
31823142
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-
// },
31903143
},
31913144
async ({ controller, initialState, encryptor }) => {
31923145
jest.spyOn(encryptor, 'decryptWithKey').mockResolvedValueOnce([
@@ -3214,13 +3167,6 @@ describe('KeyringController', () => {
32143167
await withController(
32153168
{
32163169
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-
// },
32243170
},
32253171
async ({ controller, initialState, encryptor }) => {
32263172
const encryptWithKeySpy = jest.spyOn(encryptor, 'encryptWithKey');

0 commit comments

Comments
 (0)