@@ -36,13 +36,13 @@ describe('handleStop', () => {
36
36
it ( 'should work with memory store' , async ( ) => {
37
37
const store = new MemoryStore ( ) ;
38
38
await handleStopTest ( store ) ;
39
- } , 10000 ) ;
39
+ } , 20000 ) ;
40
40
41
41
it ( 'should work with leveldb store' , async ( ) => {
42
42
const walletId = walletUtils . getWalletIdFromXPub ( accessData . xpubkey ) ;
43
43
const store = new LevelDBStore ( walletId , DATA_DIR ) ;
44
44
await handleStopTest ( store ) ;
45
- } , 10000 ) ;
45
+ } , 20000 ) ;
46
46
47
47
/**
48
48
* @param {IStore } store
@@ -81,6 +81,7 @@ describe('handleStop', () => {
81
81
// Nothing changed in the store
82
82
await expect ( store . historyCount ( ) ) . resolves . toEqual ( 1 ) ;
83
83
await expect ( store . addressCount ( ) ) . resolves . toEqual ( 20 ) ;
84
+ await expect ( store . isTokenRegistered ( testToken . uid ) ) . resolves . toBeTruthy ( ) ;
84
85
tokens = await toArray ( storage . getRegisteredTokens ( ) ) ;
85
86
expect ( tokens ) . toHaveLength ( 1 ) ;
86
87
expect ( tokens [ 0 ] ) . toEqual ( testToken ) ;
@@ -90,6 +91,7 @@ describe('handleStop', () => {
90
91
// Will clean the history bit not addresses or registered tokens
91
92
await expect ( store . historyCount ( ) ) . resolves . toEqual ( 0 ) ;
92
93
await expect ( store . addressCount ( ) ) . resolves . toEqual ( 20 ) ;
94
+ await expect ( store . isTokenRegistered ( testToken . uid ) ) . resolves . toBeTruthy ( ) ;
93
95
tokens = await toArray ( storage . getRegisteredTokens ( ) ) ;
94
96
expect ( tokens ) . toHaveLength ( 1 ) ;
95
97
expect ( tokens [ 0 ] ) . toEqual ( testToken ) ;
@@ -106,10 +108,19 @@ describe('handleStop', () => {
106
108
// Will clean the history bit not addresses
107
109
await expect ( store . historyCount ( ) ) . resolves . toEqual ( 1 ) ;
108
110
await expect ( store . addressCount ( ) ) . resolves . toEqual ( 0 ) ;
111
+ await expect ( store . isTokenRegistered ( testToken . uid ) ) . resolves . toBeTruthy ( ) ;
109
112
tokens = await toArray ( storage . getRegisteredTokens ( ) ) ;
110
113
expect ( tokens ) . toHaveLength ( 1 ) ;
111
114
expect ( tokens [ 0 ] ) . toEqual ( testToken ) ;
112
115
116
+ // handleStop with cleanAddresses = true
117
+ await loadAddresses ( 0 , 20 , storage ) ;
118
+ await storage . handleStop ( { cleanTokens : true } ) ;
119
+ // Will clean the history bit not addresses
120
+ await expect ( store . historyCount ( ) ) . resolves . toEqual ( 1 ) ;
121
+ await expect ( store . addressCount ( ) ) . resolves . toEqual ( 20 ) ;
122
+ await expect ( store . isTokenRegistered ( testToken . uid ) ) . resolves . toBeFalsy ( ) ;
123
+
113
124
// Access data is untouched when stopping the wallet
114
125
// XXX: since we stringify to save on store, the optional undefined properties are removed
115
126
// Since they are optional and unset, we can safely remove them from the expected value
0 commit comments