mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
25 lines
458 B
Go
25 lines
458 B
Go
package metrics
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestMeterDecay(t *testing.T) {
|
|
ma := meterArbiter{
|
|
ticker: time.NewTicker(time.Millisecond),
|
|
meters: make(map[*StandardMeter]struct{}),
|
|
}
|
|
defer ma.ticker.Stop()
|
|
m := newStandardMeter()
|
|
ma.meters[m] = struct{}{}
|
|
m.Mark(1)
|
|
ma.tickMeters()
|
|
rateMean := m.RateMean()
|
|
time.Sleep(100 * time.Millisecond)
|
|
ma.tickMeters()
|
|
if m.RateMean() >= rateMean {
|
|
t.Error("m.RateMean() didn't decrease")
|
|
}
|
|
}
|