]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tai64n: account for whitening in test
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 29 May 2019 16:43:17 +0000 (18:43 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 29 May 2019 16:44:53 +0000 (18:44 +0200)
tai64n/tai64n_test.go

index 36b0c57d6ea23879b08c4fba9fedb219a2e3f862..859660f93cc7d24fe438fbc0e01640e213da8db4 100644 (file)
@@ -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
        }