[tor-commits] [meek/master] Can use bytes.Reader, don't need bytes.Buffer.

dcf at torproject.org dcf at torproject.org
Tue Mar 5 23:21:26 UTC 2019


commit 5848703da3fbf48b4d67b5abd48171cd4935dca7
Author: David Fifield <david at bamsoftware.com>
Date:   Tue Mar 5 16:19:50 2019 -0700

    Can use bytes.Reader, don't need bytes.Buffer.
---
 meek-client-torbrowser/protocol_test.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/meek-client-torbrowser/protocol_test.go b/meek-client-torbrowser/protocol_test.go
index e127c4f..63e48d2 100644
--- a/meek-client-torbrowser/protocol_test.go
+++ b/meek-client-torbrowser/protocol_test.go
@@ -53,13 +53,13 @@ func TestGrepHelperAddr(t *testing.T) {
 		"meek-http-helper: listen " + expectedAddr + " \n",
 		"meek-http-helper: listen " + expectedAddr + "abc\n",
 	} {
-		b := bytes.NewBufferString(test)
+		b := bytes.NewReader([]byte(test))
 		s, err := grepHelperAddrTimeout(b)
 		if err != io.EOF {
 			t.Errorf("%q → (%q, %v), should have been %v", test, s, err, io.EOF)
 		}
 		// test again with an endless reader
-		b = bytes.NewBufferString(test)
+		b = bytes.NewReader([]byte(test))
 		s, err = grepHelperAddrTimeout(io.MultiReader(b, &infiniteReader{}))
 		if err != errTimedout {
 			t.Errorf("%q → (%q, %v), should have been %v", test, s, err, errTimedout)
@@ -73,13 +73,13 @@ func TestGrepHelperAddr(t *testing.T) {
 		"junk\nmeek-http-helper: listen " + expectedAddr + "\njunk",
 		"meek-http-helper: listen " + expectedAddr + "\nmeek-http-helper: listen 1.2.3.4:9999\n",
 	} {
-		b := bytes.NewBufferString(test)
+		b := bytes.NewReader([]byte(test))
 		s, err := grepHelperAddrTimeout(b)
 		if err != nil || s != expectedAddr {
 			t.Errorf("%q → (%q, %v), should have been %q", test, s, err, expectedAddr)
 		}
 		// test again with an endless reader
-		b = bytes.NewBufferString(test)
+		b = bytes.NewReader([]byte(test))
 		s, err = grepHelperAddrTimeout(io.MultiReader(b, &infiniteReader{}))
 		if err != nil || s != expectedAddr {
 			t.Errorf("%q → (%q, %v), should have been %q", test, s, err, expectedAddr)





More information about the tor-commits mailing list