diff options
author | Tamir Duberstein <tamird@google.com> | 2021-05-25 11:38:33 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-25 11:41:18 -0700 |
commit | b8052176db03f5d357ca50adf1e90cfecccbc001 (patch) | |
tree | e326b95b9306b41fa7b0e6e8b11b6b80bd737a6f /pkg/tcpip/stack/nud_test.go | |
parent | 090ee43a1ced12d2f55e00dcd01813a4f3ea1ae5 (diff) |
Use the stack RNG
Remove redundant interface.
PiperOrigin-RevId: 375756254
Diffstat (limited to 'pkg/tcpip/stack/nud_test.go')
-rw-r--r-- | pkg/tcpip/stack/nud_test.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pkg/tcpip/stack/nud_test.go b/pkg/tcpip/stack/nud_test.go index 6ba97d626..d85213fba 100644 --- a/pkg/tcpip/stack/nud_test.go +++ b/pkg/tcpip/stack/nud_test.go @@ -16,6 +16,7 @@ package stack_test import ( "math" + "math/rand" "testing" "time" @@ -46,12 +47,14 @@ type fakeRand struct { num float32 } -var _ stack.Rand = (*fakeRand)(nil) +var _ rand.Source = (*fakeRand)(nil) -func (f *fakeRand) Float32() float32 { - return f.num +func (f *fakeRand) Int63() int64 { + return int64(f.num * float32(1<<63)) } +func (*fakeRand) Seed(int64) {} + func TestNUDFunctions(t *testing.T) { const nicID = 1 @@ -708,7 +711,7 @@ func TestNUDStateReachableTime(t *testing.T) { rng := fakeRand{ num: defaultFakeRandomNum, } - s := stack.NewNUDState(c, &rng) + s := stack.NewNUDState(c, rand.New(&rng)) if got, want := s.ReachableTime(), test.want; got != want { t.Errorf("got ReachableTime = %q, want = %q", got, want) } @@ -780,7 +783,7 @@ func TestNUDStateRecomputeReachableTime(t *testing.T) { rng := fakeRand{ num: defaultFakeRandomNum, } - s := stack.NewNUDState(c, &rng) + s := stack.NewNUDState(c, rand.New(&rng)) old := s.ReachableTime() if got, want := s.ReachableTime(), old; got != want { |