@@ -308,25 +308,12 @@ describe("DatabaseService.restoreCurrentRound", () => {
308
308
stateStore . getLastBlocksByHeight . mockReturnValueOnce ( lastBlocksByHeight ) ;
309
309
blockRepository . findByHeightRangeWithTransactions . mockReturnValueOnce ( lastBlocksByHeight ) ;
310
310
311
- const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) } ;
311
+ const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) , revert : jest . fn ( ) } ;
312
312
getDposPreviousRoundState . mockReturnValueOnce ( prevRoundState ) ;
313
313
314
- const prevRoundDelegateWallet = { getAttribute : jest . fn ( ) } ;
315
- const prevRoundDposStateAllDelegates = [ prevRoundDelegateWallet ] ;
316
- prevRoundState . getAllDelegates . mockReturnValueOnce ( prevRoundDposStateAllDelegates ) ;
317
-
318
- const prevRoundDelegateUsername = "test_delegate" ;
319
- prevRoundDelegateWallet . getAttribute . mockReturnValueOnce ( prevRoundDelegateUsername ) ;
320
-
321
314
const delegateWallet = { setAttribute : jest . fn ( ) , getAttribute : jest . fn ( ) } ;
322
315
walletRepository . findByUsername . mockReturnValueOnce ( delegateWallet ) ;
323
316
324
- const prevRoundDelegateRank = 1 ;
325
- prevRoundDelegateWallet . getAttribute . mockReturnValueOnce ( prevRoundDelegateRank ) ;
326
-
327
- const prevRoundDposStateRoundDelegates = [ prevRoundDelegateWallet ] ;
328
- prevRoundState . getRoundDelegates . mockReturnValueOnce ( prevRoundDposStateRoundDelegates ) ;
329
-
330
317
const dposStateRoundDelegates = [ delegateWallet ] ;
331
318
dposState . getRoundDelegates . mockReturnValueOnce ( dposStateRoundDelegates ) ;
332
319
dposState . getRoundDelegates . mockReturnValueOnce ( dposStateRoundDelegates ) ;
@@ -336,9 +323,9 @@ describe("DatabaseService.restoreCurrentRound", () => {
336
323
337
324
await databaseService . restoreCurrentRound ( 1760000 ) ;
338
325
339
- expect ( getDposPreviousRoundState ) . toBeCalled ( ) ;
340
- expect ( walletRepository . findByUsername ) . toBeCalledWith ( prevRoundDelegateUsername ) ;
341
- expect ( delegateWallet . setAttribute ) . toBeCalledWith ( "delegate.rank ", prevRoundDelegateRank ) ;
326
+ expect ( getDposPreviousRoundState ) . not . toBeCalled ( ) ; // restoring current round should not need previous round state
327
+ // important: getActiveDelegates should be called with only roundInfo (restoreCurrentRound does *not* provide delegates to it)
328
+ expect ( triggers . call ) . toHaveBeenLastCalledWith ( "getActiveDelegates ", { roundInfo : expect . anything ( ) , delegates : undefined } ) ;
342
329
expect ( databaseService . forgingDelegates ) . toEqual ( forgingDelegates ) ;
343
330
} ) ;
344
331
} ) ;
@@ -985,8 +972,8 @@ describe("DatabaseService.revertRound", () => {
985
972
stateStore . getLastBlocksByHeight . mockReturnValueOnce ( [ lastBlock . data ] ) ;
986
973
blockRepository . findByHeightRangeWithTransactions . mockReturnValueOnce ( [ lastBlock . data ] ) ;
987
974
988
- const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) } ;
989
- getDposPreviousRoundState . mockReturnValueOnce ( prevRoundState ) ;
975
+ const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) , revert : jest . fn ( ) } ;
976
+ getDposPreviousRoundState . mockReturnValueOnce ( prevRoundState ) . mockReturnValueOnce ( prevRoundState ) ;
990
977
991
978
const prevRoundDelegateWallet = { getAttribute : jest . fn ( ) } ;
992
979
const prevRoundDposStateAllDelegates = [ prevRoundDelegateWallet ] ;
0 commit comments