From 5731b5256b8e3d314504cf7569710cbcd84422c6 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Mon, 3 Jul 2017 15:38:55 -0700 Subject: [PATCH] archive/zip, crypto/tls: use rand.Read instead of casting ints to bytes Makes tests run ~1ms faster. Change-Id: Ida509952469540280996d2bd9266724829e53c91 Reviewed-on: https://go-review.googlesource.com/47359 Reviewed-by: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Gobot Gobot --- handshake_messages_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handshake_messages_test.go b/handshake_messages_test.go index aa7f937..37eb748 100644 --- a/handshake_messages_test.go +++ b/handshake_messages_test.go @@ -98,8 +98,8 @@ func TestFuzz(t *testing.T) { func randomBytes(n int, rand *rand.Rand) []byte { r := make([]byte, n) - for i := 0; i < n; i++ { - r[i] = byte(rand.Int31()) + if _, err := rand.Read(r); err != nil { + panic("rand.Read failed: " + err.Error()) } return r }