@@ -48,9 +48,6 @@ type testTimer struct {
48
48
// At is the time this timer is scheduled for in test time
49
49
At time.Time
50
50
51
- // WallClockAt is the time this timer is scheduled for in wall-clock time
52
- WallClockAt time.Time
53
-
54
51
// Callback is called when the timer should fire.
55
52
Callback * func ()
56
53
@@ -428,28 +425,21 @@ func (wt *workflowTester[TResult]) fireTimer() bool {
428
425
{
429
426
t := wt .timers [0 ]
430
427
431
- wt .logger .Debug ("Scheduling wall-clock timer" , "at" , t .WallClockAt )
432
-
433
- // wt.nextTimer = t
428
+ wt .logger .Debug ("Scheduling wall-clock timer" , "at" , t .At )
434
429
435
- if wt .wallClock .Now ().After (t .WallClockAt ) {
436
- // Fire timer
437
- wt .timers = wt .timers [1 :]
438
- wt .callbacks <- t .fire
430
+ // Determine when this should run
431
+ remainingTime := t .At .Sub (wt .clock .Now ())
439
432
440
- return true
441
- } else if wt .wallClockTimer == nil {
442
- // Schedule timer
443
- wt .wallClockTimer = wt .wallClock .AfterFunc (t .WallClockAt .Sub (wt .wallClock .Now ()), func () {
444
- wt .callbacks <- func () * history.WorkflowEvent {
445
- // Remove timer
446
- wt .timers = wt .timers [1 :]
447
- wt .wallClockTimer = nil
433
+ // Schedule timer
434
+ wt .wallClockTimer = wt .wallClock .AfterFunc (remainingTime , func () {
435
+ wt .callbacks <- func () * history.WorkflowEvent {
436
+ // Remove timer
437
+ wt .timers = wt .timers [1 :]
438
+ wt .wallClockTimer = nil
448
439
449
- return t .fire ()
450
- }
451
- })
452
- }
440
+ return t .fire ()
441
+ }
442
+ })
453
443
}
454
444
}
455
445
@@ -633,7 +623,6 @@ func (wt *workflowTester[TResult]) scheduleTimer(instance *core.WorkflowInstance
633
623
Instance : instance ,
634
624
ScheduleEventID : event .ScheduleEventID ,
635
625
At : e .At ,
636
- WallClockAt : wt .wallClock .Now ().Add (e .At .Sub (wt .clock .Now ())),
637
626
TimerEvent : & history.WorkflowEvent {
638
627
WorkflowInstance : instance ,
639
628
HistoryEvent : event ,
0 commit comments