@@ -12,13 +12,15 @@ import { mockLastBlock, setup } from "./setup";
1212
1313let delegateTracker : DelegateTracker ;
1414let loggerDebug : jest . SpyInstance ;
15+ let loggerWarning : jest . SpyInstance ;
1516let activeDelegates ;
1617
1718beforeEach ( async ( ) => {
1819 activeDelegates = calculateActiveDelegates ( ) ;
1920 const initialEnv = await setup ( activeDelegates ) ;
2021 delegateTracker = initialEnv . sandbox . app . resolve < DelegateTracker > ( DelegateTracker ) ;
2122 loggerDebug = initialEnv . spies . logger . debug ;
23+ loggerWarning = initialEnv . spies . logger . warning ;
2224} ) ;
2325
2426beforeEach ( ( ) => {
@@ -119,7 +121,7 @@ describe("DelegateTracker", () => {
119121 }
120122 } ) ;
121123
122- it ( "should handle cases where there are less active delegates than the required delegate count" , async ( ) => {
124+ it ( "should log warning when there are less active delegates than the required delegate count" , async ( ) => {
123125 const mockMileStoneData = {
124126 blocktime : 2 ,
125127 activeDelegates : 80 ,
@@ -130,20 +132,9 @@ describe("DelegateTracker", () => {
130132 delegateTracker . initialize ( activeDelegates ) ;
131133 await delegateTracker . handle ( ) ;
132134
133- /**
134- * TODO: check this is desired behaviour
135- * When there are less activeDelegates than required this behaves differently.
136- * In this case, the first entry in nextDelegates is calculated as forging next (as opposed to the second delegate in the test above).
137- * We also don't calculate (or log) the time until forging for any delegate.
138- */
139- for ( let i = 0 ; i < activeDelegates . length ; i ++ ) {
140- const nextToForge = activeDelegates [ i ] ;
141- if ( i === 0 ) {
142- expect ( loggerDebug ) . toHaveBeenCalledWith ( `${ nextToForge . publicKey } will forge next.` ) ;
143- } else {
144- expect ( loggerDebug ) . toHaveBeenNthCalledWith ( i + 2 , `${ nextToForge . publicKey } has already forged.` ) ;
145- }
146- }
135+ expect ( loggerWarning ) . toHaveBeenCalledWith (
136+ `Tracker only has ${ activeDelegates . length } active delegates from a required ${ mockMileStoneData . activeDelegates } ` ,
137+ ) ;
147138 } ) ;
148139 } ) ;
149140} ) ;
0 commit comments