refactor: move bytecounter to internal (#391)
It's generic enough to live outside of engine/netx. Occurred to me while working on https://github.com/ooni/probe/issues/1687.
This commit is contained in:
parent
520398dd8e
commit
23bc261464
14 changed files with 23 additions and 20 deletions
|
|
@ -1,27 +0,0 @@
|
|||
package bytecounter_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/bytecounter"
|
||||
)
|
||||
|
||||
func TestGood(t *testing.T) {
|
||||
counter := bytecounter.New()
|
||||
counter.CountBytesReceived(16384)
|
||||
counter.CountKibiBytesReceived(10)
|
||||
counter.CountBytesSent(2048)
|
||||
counter.CountKibiBytesSent(10)
|
||||
if counter.BytesSent() != 12288 {
|
||||
t.Fatal("invalid bytes sent")
|
||||
}
|
||||
if counter.BytesReceived() != 26624 {
|
||||
t.Fatal("invalid bytes received")
|
||||
}
|
||||
if v := counter.KibiBytesSent(); v < 11.9 || v > 12.1 {
|
||||
t.Fatal("invalid kibibytes sent")
|
||||
}
|
||||
if v := counter.KibiBytesReceived(); v < 25.9 || v > 26.1 {
|
||||
t.Fatal("invalid kibibytes received")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue