@@ -39,7 +39,6 @@ import {
39
39
import MockEncryptor , {
40
40
DECRYPTION_ERROR ,
41
41
MOCK_ENCRYPTION_KEY ,
42
- PASSWORD ,
43
42
} from '../tests/mocks/mockEncryptor' ;
44
43
import { MockErc4337Keyring } from '../tests/mocks/mockErc4337Keyring' ;
45
44
import { MockKeyring } from '../tests/mocks/mockKeyring' ;
@@ -555,20 +554,13 @@ describe('KeyringController', () => {
555
554
await withController (
556
555
{ cacheEncryptionKey } ,
557
556
async ( { controller, initialState } ) => {
558
- // const initialVault = controller.state.vault;
559
557
const initialKeyrings = controller . state . keyrings ;
560
558
await controller . createNewVaultAndRestore (
561
559
password ,
562
560
uint8ArraySeed ,
563
561
) ;
564
562
expect ( controller . state ) . not . toBe ( initialState ) ;
565
563
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);
572
564
expect ( controller . state . keyrings ) . toHaveLength (
573
565
initialKeyrings . length ,
574
566
) ;
@@ -597,7 +589,8 @@ describe('KeyringController', () => {
597
589
currentSeedWord ,
598
590
) ;
599
591
600
- expect ( encryptSpy ) . toHaveBeenCalledWith ( expect . any ( Object ) , [
592
+ const key = JSON . parse ( MOCK_ENCRYPTION_KEY ) ;
593
+ expect ( encryptSpy ) . toHaveBeenCalledWith ( key , [
601
594
{
602
595
data : serializedKeyring ,
603
596
type : 'HD Key Tree' ,
@@ -644,10 +637,6 @@ describe('KeyringController', () => {
644
637
await withController (
645
638
{ cacheEncryptionKey } ,
646
639
async ( { controller } ) => {
647
- // await controller.createNewVaultAndRestore(
648
- // password,
649
- // uint8ArraySeed,
650
- // );
651
640
expect ( controller . state . encryptionKey ) . toBeDefined ( ) ;
652
641
expect ( controller . state . encryptionSalt ) . toBeDefined ( ) ;
653
642
} ,
@@ -2700,8 +2689,6 @@ describe('KeyringController', () => {
2700
2689
await withController (
2701
2690
{
2702
2691
cacheEncryptionKey,
2703
- // skipVaultCreation: true,
2704
- // state: { vault: 'my vault' },
2705
2692
} ,
2706
2693
async ( { controller, encryptor } ) => {
2707
2694
jest . spyOn ( encryptor , 'decryptWithKey' ) . mockResolvedValueOnce ( [
@@ -2722,8 +2709,6 @@ describe('KeyringController', () => {
2722
2709
await withController (
2723
2710
{
2724
2711
cacheEncryptionKey,
2725
- // skipVaultCreation: true,
2726
- // state: { vault: 'my vault' },
2727
2712
} ,
2728
2713
async ( { controller, encryptor } ) => {
2729
2714
jest . spyOn ( encryptor , 'decryptWithKey' ) . mockResolvedValueOnce ( [
@@ -2756,8 +2741,6 @@ describe('KeyringController', () => {
2756
2741
await withController (
2757
2742
{
2758
2743
cacheEncryptionKey,
2759
- // state: { vault: 'my vault' },
2760
- // skipVaultCreation: true,
2761
2744
} ,
2762
2745
async ( { controller, encryptor } ) => {
2763
2746
jest . spyOn ( encryptor , 'decryptWithKey' ) . mockResolvedValueOnce ( [
@@ -2798,10 +2781,6 @@ describe('KeyringController', () => {
2798
2781
await withController (
2799
2782
{
2800
2783
cacheEncryptionKey : true ,
2801
- // state: {
2802
- // vault: 'my vault',
2803
- // },
2804
- // skipVaultCreation: true,
2805
2784
} ,
2806
2785
async ( { controller, encryptor } ) => {
2807
2786
const encryptWithKeySpy = jest . spyOn (
@@ -2861,10 +2840,6 @@ describe('KeyringController', () => {
2861
2840
await withController (
2862
2841
{
2863
2842
cacheEncryptionKey : false ,
2864
- state : {
2865
- vault : 'my vault' ,
2866
- } ,
2867
- skipVaultCreation : true ,
2868
2843
} ,
2869
2844
async ( { controller, encryptor } ) => {
2870
2845
const encryptSpy = jest . spyOn ( encryptor , 'encrypt' ) ;
@@ -2915,9 +2890,7 @@ describe('KeyringController', () => {
2915
2890
stubKeyringClassWithAccount ( HdKeyring , '0x123' ) ;
2916
2891
await withController (
2917
2892
{
2918
- // skipVaultCreation: true,
2919
2893
cacheEncryptionKey,
2920
- // state: { vault: 'my vault' },
2921
2894
keyringBuilders : [ keyringBuilderFactory ( MockKeyring ) ] ,
2922
2895
} ,
2923
2896
async ( { controller, encryptor, messenger } ) => {
@@ -2946,9 +2919,7 @@ describe('KeyringController', () => {
2946
2919
it ( 'should unlock the wallet also if encryption parameters are outdated and the vault upgrade fails' , async ( ) => {
2947
2920
await withController (
2948
2921
{
2949
- // skipVaultCreation: true,
2950
2922
cacheEncryptionKey,
2951
- // state: { vault: 'my vault' },
2952
2923
} ,
2953
2924
async ( { controller, encryptor } ) => {
2954
2925
jest . spyOn ( encryptor , 'isVaultUpdated' ) . mockReturnValue ( false ) ;
@@ -2975,9 +2946,7 @@ describe('KeyringController', () => {
2975
2946
stubKeyringClassWithAccount ( HdKeyring , '0x123' ) ;
2976
2947
await withController (
2977
2948
{
2978
- // skipVaultCreation: true,
2979
2949
cacheEncryptionKey,
2980
- // state: { vault: 'my vault' },
2981
2950
keyringBuilders : [ keyringBuilderFactory ( MockKeyring ) ] ,
2982
2951
} ,
2983
2952
async ( { controller, encryptor, messenger } ) => {
@@ -3006,9 +2975,7 @@ describe('KeyringController', () => {
3006
2975
it ( 'should upgrade the vault encryption if the key encryptor has different parameters' , async ( ) => {
3007
2976
await withController (
3008
2977
{
3009
- // skipVaultCreation: true,
3010
2978
cacheEncryptionKey,
3011
- // state: { vault: 'my vault' },
3012
2979
} ,
3013
2980
async ( { controller, encryptor } ) => {
3014
2981
jest . spyOn ( encryptor , 'isVaultUpdated' ) . mockReturnValue ( false ) ;
@@ -3033,9 +3000,7 @@ describe('KeyringController', () => {
3033
3000
it ( 'should not upgrade the vault encryption if the key encryptor has the same parameters' , async ( ) => {
3034
3001
await withController (
3035
3002
{
3036
- // skipVaultCreation: true,
3037
3003
cacheEncryptionKey,
3038
- // state: { vault: 'my vault' },
3039
3004
} ,
3040
3005
async ( { controller, encryptor } ) => {
3041
3006
jest . spyOn ( encryptor , 'isVaultUpdated' ) . mockReturnValue ( true ) ;
@@ -3064,9 +3029,7 @@ describe('KeyringController', () => {
3064
3029
it ( 'should upgrade the vault encryption if the generic encryptor has different parameters' , async ( ) => {
3065
3030
await withController (
3066
3031
{
3067
- skipVaultCreation : true ,
3068
3032
cacheEncryptionKey,
3069
- state : { vault : 'my vault' } ,
3070
3033
} ,
3071
3034
async ( { controller, encryptor } ) => {
3072
3035
jest . spyOn ( encryptor , 'isVaultUpdated' ) . mockReturnValue ( false ) ;
@@ -3090,9 +3053,7 @@ describe('KeyringController', () => {
3090
3053
it ( 'should not upgrade the vault encryption if the encryptor has the same parameters and the keyring has metadata' , async ( ) => {
3091
3054
await withController (
3092
3055
{
3093
- // skipVaultCreation: true,
3094
3056
cacheEncryptionKey,
3095
- // state: { vault: 'my vault' },
3096
3057
} ,
3097
3058
async ( { controller, encryptor } ) => {
3098
3059
jest . spyOn ( encryptor , 'isVaultUpdated' ) . mockReturnValue ( true ) ;
@@ -3145,9 +3106,7 @@ describe('KeyringController', () => {
3145
3106
it ( 'should throw error when using the wrong password' , async ( ) => {
3146
3107
await withController (
3147
3108
{
3148
- // skipVaultCreation: true,
3149
3109
cacheEncryptionKey,
3150
- // state: { vault: 'my vault' },
3151
3110
} ,
3152
3111
async ( { controller } ) => {
3153
3112
await expect (
@@ -3178,13 +3137,6 @@ describe('KeyringController', () => {
3178
3137
await withController (
3179
3138
{
3180
3139
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
- // },
3188
3140
} ,
3189
3141
async ( { controller, initialState, encryptor } ) => {
3190
3142
jest . spyOn ( encryptor , 'decryptWithKey' ) . mockResolvedValueOnce ( [
@@ -3212,13 +3164,6 @@ describe('KeyringController', () => {
3212
3164
await withController (
3213
3165
{
3214
3166
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
- // },
3222
3167
} ,
3223
3168
async ( { controller, initialState, encryptor } ) => {
3224
3169
const encryptWithKeySpy = jest . spyOn ( encryptor , 'encryptWithKey' ) ;
0 commit comments