aboutsummaryrefslogtreecommitdiffstats
path: root/tai64n/tai64n_test.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-29 18:43:17 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-29 18:44:53 +0200
commitd0ab883adaae3b458ec6a54af04c9df347f378f5 (patch)
tree1dd65fc60683a65b7092d06b26752a207de20e48 /tai64n/tai64n_test.go
parentdevice, tun: rearrange code and fix device tests (diff)
downloadwireguard-go-d0ab883adaae3b458ec6a54af04c9df347f378f5.tar.xz
wireguard-go-d0ab883adaae3b458ec6a54af04c9df347f378f5.zip
tai64n: account for whitening in test
Diffstat (limited to '')
-rw-r--r--tai64n/tai64n_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/tai64n/tai64n_test.go b/tai64n/tai64n_test.go
index 36b0c57..859660f 100644
--- a/tai64n/tai64n_test.go
+++ b/tai64n/tai64n_test.go
@@ -15,11 +15,15 @@ import (
*/
func TestMonotonic(t *testing.T) {
old := Now()
- for i := 0; i < 10000; i++ {
- time.Sleep(time.Nanosecond)
+ for i := 0; i < 50; i++ {
next := Now()
+ if next.After(old) {
+ t.Error("Whitening insufficient")
+ }
+ time.Sleep(time.Duration(whitenerMask)/time.Nanosecond + 1)
+ next = Now()
if !next.After(old) {
- t.Error("TAI64N, not monotonically increasing on nano-second scale")
+ t.Error("Not monotonically increasing on whitened nano-second scale")
}
old = next
}