Skip to content

Commit

Permalink
fix timeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Jul 30, 2024
1 parent b8e7fac commit 99d10ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestNewTimerWheel(t *testing.T) {
tw := NewTimerWheel[firewall.Packet](time.Second, time.Second*10)
assert.Equal(t, 12, tw.wheelLen)
assert.Equal(t, 0, tw.current)
assert.Nil(t, tw.lastTick)
assert.Equal(t, false, tw.lastTickValid)
assert.Equal(t, time.Second*1, tw.tickDuration)
assert.Equal(t, time.Second*10, tw.wheelDuration)
assert.Len(t, tw.wheel, 12)
Expand Down Expand Up @@ -109,9 +109,9 @@ func TestTimerWheel_Add(t *testing.T) {
func TestTimerWheel_Purge(t *testing.T) {
// First advance should set the lastTick and do nothing else
tw := NewTimerWheel[firewall.Packet](time.Second, time.Second*10)
assert.Nil(t, tw.lastTick)
assert.Equal(t, false, tw.lastTickValid)
tw.Advance(time.Now())
assert.NotNil(t, tw.lastTick)
assert.Equal(t, true, tw.lastTickValid)
assert.Equal(t, 0, tw.current)

fps := []firewall.Packet{
Expand All @@ -127,7 +127,7 @@ func TestTimerWheel_Purge(t *testing.T) {
tw.Add(fps[3], time.Second*2)

ta := time.Now().Add(time.Second * 3)
lastTick := *tw.lastTick
lastTick := tw.lastTick
tw.Advance(ta)
assert.Equal(t, 3, tw.current)
assert.True(t, tw.lastTick.After(lastTick))
Expand Down

0 comments on commit 99d10ec

Please sign in to comment.