@@ -12,13 +12,15 @@ import { mockLastBlock, setup } from "./setup";
12
12
13
13
let delegateTracker : DelegateTracker ;
14
14
let loggerDebug : jest . SpyInstance ;
15
+ let loggerWarning : jest . SpyInstance ;
15
16
let activeDelegates ;
16
17
17
18
beforeEach ( async ( ) => {
18
19
activeDelegates = calculateActiveDelegates ( ) ;
19
20
const initialEnv = await setup ( activeDelegates ) ;
20
21
delegateTracker = initialEnv . sandbox . app . resolve < DelegateTracker > ( DelegateTracker ) ;
21
22
loggerDebug = initialEnv . spies . logger . debug ;
23
+ loggerWarning = initialEnv . spies . logger . warning ;
22
24
} ) ;
23
25
24
26
beforeEach ( ( ) => {
@@ -119,7 +121,7 @@ describe("DelegateTracker", () => {
119
121
}
120
122
} ) ;
121
123
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 ( ) => {
123
125
const mockMileStoneData = {
124
126
blocktime : 2 ,
125
127
activeDelegates : 80 ,
@@ -130,20 +132,9 @@ describe("DelegateTracker", () => {
130
132
delegateTracker . initialize ( activeDelegates ) ;
131
133
await delegateTracker . handle ( ) ;
132
134
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
+ ) ;
147
138
} ) ;
148
139
} ) ;
149
140
} ) ;
0 commit comments