Skip to content
Snippets Groups Projects
Commit 8cb463f9 authored by David Stainton's avatar David Stainton
Browse files

timeTracker: add TestAddOffset

parent 369d639c
Branches
Tags
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!404Add rough draft timeTracker,!340Project/channels
......@@ -10,6 +10,7 @@ package timeTracker
import (
"crypto/rand"
"sync"
"testing"
"time"
......@@ -65,3 +66,19 @@ func TestGatewayDelayAverage(t *testing.T) {
avg := gwDelays.Average()
require.Equal(t, int(avg), 265)
}
func TestAddOffset(t *testing.T) {
tracker := &timeOffsetTracker{
gatewayClockDelays: new(sync.Map),
offsets: make([]*time.Duration, maxHistogramSize),
currentIndex: 0,
}
offset := time.Second * 10
for i := 0; i < maxHistogramSize-1; i++ {
tracker.addOffset(offset)
require.Equal(t, i+1, tracker.currentIndex)
}
tracker.addOffset(offset)
require.Equal(t, 0, tracker.currentIndex)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment