@@ -12,10 +12,11 @@ import { StateBuilder } from "@packages/core-state/src/state-builder";
12
12
import { StateStore } from "@packages/core-state/src/stores/state" ;
13
13
import { TransactionValidator } from "@packages/core-state/src/transaction-validator" ;
14
14
import { WalletRepository , WalletRepositoryClone , WalletRepositoryCopyOnWrite } from "@packages/core-state/src/wallets" ;
15
- import { registerFactories , registerIndexers } from "@packages/core-state/src/wallets/indexers" ;
15
+ import { registerIndexers } from "@packages/core-state/src/wallets/indexers" ;
16
16
import { Sandbox } from "@packages/core-test-framework/src" ;
17
17
import { Factories , FactoryBuilder } from "@packages/core-test-framework/src/factories" ;
18
18
import { Managers , Utils } from "@packages/crypto/src" ;
19
+ import { walletFactory } from "@arkecosystem/core-state/src/wallets/wallet-factory" ;
19
20
20
21
export interface Spies {
21
22
applySpy : jest . SpyInstance ;
@@ -31,6 +32,7 @@ export interface Spies {
31
32
getSentTransactionSpy : jest . SpyInstance ;
32
33
getRegisteredHandlersSpy : jest . SpyInstance ;
33
34
dispatchSpy : jest . SpyInstance ;
35
+ dispatchSyncSpy : jest . SpyInstance ;
34
36
}
35
37
36
38
export interface Setup {
@@ -145,7 +147,6 @@ export const setUp = async (setUpOptions = setUpDefaults, skipBoot = false): Pro
145
147
// });
146
148
147
149
registerIndexers ( sandbox . app ) ;
148
- registerFactories ( sandbox . app ) ;
149
150
150
151
sandbox . app . bind ( Container . Identifiers . PluginConfiguration ) . to ( Providers . PluginConfiguration ) . inSingletonScope ( ) ;
151
152
@@ -166,42 +167,6 @@ export const setUp = async (setUpOptions = setUpDefaults, skipBoot = false): Pro
166
167
167
168
const stateStore : StateStore = sandbox . app . get ( Container . Identifiers . StateStore ) ;
168
169
169
- sandbox . app
170
- . bind ( Container . Identifiers . WalletRepository )
171
- . to ( WalletRepository )
172
- . inSingletonScope ( )
173
- . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "blockchain" ) ) ;
174
-
175
- sandbox . app
176
- . bind ( Container . Identifiers . WalletRepository )
177
- . to ( WalletRepositoryClone )
178
- . inRequestScope ( )
179
- . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "clone" ) ) ;
180
-
181
- sandbox . app
182
- . bind ( Container . Identifiers . WalletRepository )
183
- . to ( WalletRepositoryCopyOnWrite )
184
- . inRequestScope ( )
185
- . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "copy-on-write" ) ) ;
186
-
187
- const walletRepoClone : WalletRepositoryClone = sandbox . app . getTagged (
188
- Container . Identifiers . WalletRepository ,
189
- "state" ,
190
- "clone" ,
191
- ) ;
192
-
193
- const walletRepo : WalletRepository = sandbox . app . getTagged (
194
- Container . Identifiers . WalletRepository ,
195
- "state" ,
196
- "blockchain" ,
197
- ) ;
198
-
199
- const walletRepoCopyOnWrite : WalletRepositoryCopyOnWrite = sandbox . app . getTagged (
200
- Container . Identifiers . WalletRepository ,
201
- "state" ,
202
- "copy-on-write" ,
203
- ) ;
204
-
205
170
const applySpy : jest . SpyInstance = jest . fn ( ) ;
206
171
const revertSpy : jest . SpyInstance = jest . fn ( ) ;
207
172
@@ -244,18 +209,83 @@ export const setUp = async (setUpOptions = setUpDefaults, skipBoot = false): Pro
244
209
}
245
210
246
211
const dispatchSpy = jest . fn ( ) ;
212
+ const dispatchSyncSpy = jest . fn ( ) ;
247
213
248
214
@Container . injectable ( )
249
215
class MockEventDispatcher {
250
216
public dispatch ( data ) {
251
217
return dispatchSpy ( data ) ;
252
218
}
219
+
220
+ public dispatchSync ( data ) {
221
+ return dispatchSyncSpy ( data ) ;
222
+ }
253
223
}
254
224
255
225
sandbox . app . container . bind ( Container . Identifiers . DatabaseBlockRepository ) . to ( MockBlockRepository ) ;
256
226
sandbox . app . container . bind ( Container . Identifiers . DatabaseTransactionRepository ) . to ( MockTransactionRepository ) ;
257
227
sandbox . app . container . bind ( Container . Identifiers . EventDispatcherService ) . to ( MockEventDispatcher ) ;
258
228
229
+ sandbox . app
230
+ . bind ( Container . Identifiers . WalletRepository )
231
+ . to ( WalletRepository )
232
+ . inSingletonScope ( )
233
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "blockchain" ) ) ;
234
+
235
+ sandbox . app
236
+ . bind ( Container . Identifiers . WalletFactory )
237
+ . toFactory ( ( { container } ) => {
238
+ return walletFactory (
239
+ container . get ( Container . Identifiers . WalletAttributes ) ,
240
+ container . get ( Container . Identifiers . EventDispatcherService ) ,
241
+ ) ;
242
+ } )
243
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "blockchain" ) ) ;
244
+
245
+ sandbox . app
246
+ . bind ( Container . Identifiers . WalletRepository )
247
+ . to ( WalletRepositoryClone )
248
+ . inRequestScope ( )
249
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "clone" ) ) ;
250
+
251
+ sandbox . app
252
+ . bind ( Container . Identifiers . WalletFactory )
253
+ . toFactory ( ( { container } ) => {
254
+ return walletFactory ( container . get ( Container . Identifiers . WalletAttributes ) ) ;
255
+ } )
256
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "clone" ) ) ;
257
+
258
+ sandbox . app
259
+ . bind ( Container . Identifiers . WalletRepository )
260
+ . to ( WalletRepositoryCopyOnWrite )
261
+ . inRequestScope ( )
262
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "copy-on-write" ) ) ;
263
+
264
+ sandbox . app
265
+ . bind ( Container . Identifiers . WalletFactory )
266
+ . toFactory ( ( { container } ) => {
267
+ return walletFactory ( container . get ( Container . Identifiers . WalletAttributes ) ) ;
268
+ } )
269
+ . when ( Container . Selectors . anyAncestorOrTargetTaggedFirst ( "state" , "copy-on-write" ) ) ;
270
+
271
+ const walletRepoClone : WalletRepositoryClone = sandbox . app . getTagged (
272
+ Container . Identifiers . WalletRepository ,
273
+ "state" ,
274
+ "clone" ,
275
+ ) ;
276
+
277
+ const walletRepo : WalletRepository = sandbox . app . getTagged (
278
+ Container . Identifiers . WalletRepository ,
279
+ "state" ,
280
+ "blockchain" ,
281
+ ) ;
282
+
283
+ const walletRepoCopyOnWrite : WalletRepositoryCopyOnWrite = sandbox . app . getTagged (
284
+ Container . Identifiers . WalletRepository ,
285
+ "state" ,
286
+ "copy-on-write" ,
287
+ ) ;
288
+
259
289
sandbox . app . bind ( Container . Identifiers . BlockState ) . to ( BlockState ) ;
260
290
261
291
sandbox . app
@@ -323,6 +353,7 @@ export const setUp = async (setUpOptions = setUpDefaults, skipBoot = false): Pro
323
353
getSentTransactionSpy,
324
354
getRegisteredHandlersSpy,
325
355
dispatchSpy,
356
+ dispatchSyncSpy,
326
357
} ,
327
358
} ;
328
359
} ;
0 commit comments