@@ -308,25 +308,12 @@ describe("DatabaseService.restoreCurrentRound", () => {
308308 stateStore . getLastBlocksByHeight . mockReturnValueOnce ( lastBlocksByHeight ) ;
309309 blockRepository . findByHeightRangeWithTransactions . mockReturnValueOnce ( lastBlocksByHeight ) ;
310310
311- const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) } ;
311+ const prevRoundState = { getAllDelegates : jest . fn ( ) , getRoundDelegates : jest . fn ( ) , revert : jest . fn ( ) } ;
312312 getDposPreviousRoundState . mockReturnValueOnce ( prevRoundState ) ;
313313
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-
321314 const delegateWallet = { setAttribute : jest . fn ( ) , getAttribute : jest . fn ( ) } ;
322315 walletRepository . findByUsername . mockReturnValueOnce ( delegateWallet ) ;
323316
324- const prevRoundDelegateRank = 1 ;
325- prevRoundDelegateWallet . getAttribute . mockReturnValueOnce ( prevRoundDelegateRank ) ;
326-
327- const prevRoundDposStateRoundDelegates = [ prevRoundDelegateWallet ] ;
328- prevRoundState . getRoundDelegates . mockReturnValueOnce ( prevRoundDposStateRoundDelegates ) ;
329-
330317 const dposStateRoundDelegates = [ delegateWallet ] ;
331318 dposState . getRoundDelegates . mockReturnValueOnce ( dposStateRoundDelegates ) ;
332319 dposState . getRoundDelegates . mockReturnValueOnce ( dposStateRoundDelegates ) ;
@@ -336,9 +323,9 @@ describe("DatabaseService.restoreCurrentRound", () => {
336323
337324 await databaseService . restoreCurrentRound ( 1760000 ) ;
338325
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 } ) ;
342329 expect ( databaseService . forgingDelegates ) . toEqual ( forgingDelegates ) ;
343330 } ) ;
344331} ) ;
@@ -985,8 +972,8 @@ describe("DatabaseService.revertRound", () => {
985972 stateStore . getLastBlocksByHeight . mockReturnValueOnce ( [ lastBlock . data ] ) ;
986973 blockRepository . findByHeightRangeWithTransactions . mockReturnValueOnce ( [ lastBlock . data ] ) ;
987974
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 ) ;
990977
991978 const prevRoundDelegateWallet = { getAttribute : jest . fn ( ) } ;
992979 const prevRoundDposStateAllDelegates = [ prevRoundDelegateWallet ] ;
0 commit comments