@@ -194,43 +194,46 @@ func TestPollNewSignatures(t *testing.T) {
194194
195195func TestHandleEventCancelled (t * testing.T ) {
196196 id := [32 ]byte {1 , 2 , 3 }
197-
197+ s := newMockScheduler ( t )
198198 worker := & WorkerSolana {
199- logger : testLogger ,
199+ logger : testLogger ,
200+ scheduler : s ,
200201 }
201-
202+ s . On ( "delFromScheduler" , mock . Anything ). Return ( nil )
202203 worker .handleEventCancelled (context .Background (), SolanaTimelockCallCancelledEvent {ID : id })
203- // TODO: once scheduler is added we can assert expectation from a mock scheduler here.
204204}
205205
206206func TestHandleEventExecuted_Done (t * testing.T ) {
207207 id := [32 ]byte {4 , 5 , 6 }
208208 mockInsp := new (mocks.TimelockInspector )
209209 mockInsp .On ("IsOperationDone" , mock .Anything , "some.addr" , id ).Return (true , nil )
210-
210+ s := newMockScheduler ( t )
211211 worker := & WorkerSolana {
212212 timelockFullAddress : "some.addr" ,
213213 inspector : mockInsp ,
214+ scheduler : s ,
214215 logger : testLogger ,
215216 }
217+ s .On ("delFromScheduler" , mock .Anything ).Return (nil )
216218 event := SolanaTimelockCallExecutedEvent {ID : id , Target : solana.PublicKey {}}
217219 err := worker .handleEventExecuted (context .Background (), event )
218220 require .NoError (t , err )
219221 mockInsp .AssertExpectations (t )
220- // TODO: once scheduler is added we can assert expectation from a mock scheduler here.
221222}
222223
223224func TestHandleEventScheduled_IsOp (t * testing.T ) {
224225 id := [32 ]byte {7 , 8 , 9 }
225226 mockInsp := new (mocks.TimelockInspector )
226227 mockInsp .On ("IsOperationDone" , mock .Anything , "some.addr" , id ).Return (false , nil )
227228 mockInsp .On ("IsOperation" , mock .Anything , "some.addr" , id ).Return (true , nil )
228-
229+ s := newMockScheduler ( t )
229230 worker := & WorkerSolana {
230231 timelockFullAddress : "some.addr" ,
231232 inspector : mockInsp ,
233+ scheduler : s ,
232234 logger : testLogger ,
233235 }
236+ s .On ("addToScheduler" , mock .Anything ).Return (nil )
234237 event := SolanaTimelockCallScheduledEvent {ID : id , Target : solana.PublicKey {}}
235238 err := worker .handleEventScheduled (context .Background (), event )
236239 require .NoError (t , err )
@@ -245,6 +248,7 @@ func TestHandleEventScheduled_OperationDone(t *testing.T) {
245248 worker := & WorkerSolana {
246249 timelockFullAddress : "some.addr" ,
247250 inspector : mockInsp ,
251+ scheduler : newMockScheduler (t ),
248252 logger : testLogger ,
249253 }
250254 event := SolanaTimelockCallScheduledEvent {ID : id , Target : solana.PublicKey {}}
@@ -261,13 +265,13 @@ func TestHandleEventExecuted_NotDone(t *testing.T) {
261265 worker := & WorkerSolana {
262266 timelockFullAddress : "some.addr" ,
263267 inspector : mockInsp ,
268+ scheduler : newMockScheduler (t ),
264269 logger : testLogger ,
265270 }
266271 event := SolanaTimelockCallExecutedEvent {ID : id , Target : solana.PublicKey {}}
267272 err := worker .handleEventExecuted (context .Background (), event )
268273 require .NoError (t , err )
269274 mockInsp .AssertExpectations (t )
270- // TODO: once scheduler is added we can assert expectation from a mock scheduler here.
271275}
272276
273277func TestHandleEventScheduled_IsOp_Error (t * testing.T ) {
@@ -279,6 +283,7 @@ func TestHandleEventScheduled_IsOp_Error(t *testing.T) {
279283 worker := & WorkerSolana {
280284 timelockFullAddress : "some.addr" ,
281285 inspector : mockInsp ,
286+ scheduler : newMockScheduler (t ),
282287 logger : testLogger ,
283288 }
284289 event := SolanaTimelockCallScheduledEvent {ID : id , Target : solana.PublicKey {}}
@@ -293,9 +298,9 @@ func TestHandleEventExecuted_Error(t *testing.T) {
293298 worker := & WorkerSolana {
294299 timelockFullAddress : "some.addr" ,
295300 inspector : mockInsp ,
301+ scheduler : newMockScheduler (t ),
296302 logger : testLogger ,
297303 }
298304 event := SolanaTimelockCallExecutedEvent {ID : id , Target : solana.PublicKey {}}
299305 require .ErrorContains (t , worker .handleEventExecuted (context .Background (), event ), "timelock.isOperationDone call failed" )
300- // TODO: once scheduler is added we can assert expectation from a mock scheduler here.
301306}
0 commit comments