commit 58b259d4dfb92fe712375553bf63f28b644f5f03 Author: David Fifield david@bamsoftware.com Date: Tue Nov 26 23:19:00 2013 -0800
Add test for extOrPortSendDone. --- pt_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/pt_test.go b/pt_test.go index cd9c280..5628a96 100644 --- a/pt_test.go +++ b/pt_test.go @@ -470,3 +470,22 @@ func TestExtOrSendUserAddr(t *testing.T) { } } } + +func TestExtOrPortSendDone(t *testing.T) { + expected := []byte("\x00\x00\x00\x00") + + var buf bytes.Buffer + err := extOrPortSendDone(&buf) + if err != nil { + t.Errorf("unexpectedly returned an error: %s", err) + } + p := make([]byte, 1024) + n, err := buf.Read(p) + if err != nil { + t.Fatal(err) + } + output := p[:n] + if !bytes.Equal(output, expected) { + t.Errorf("→ %s (expected %s)", fmtBytes(output), fmtBytes(expected)) + } +}
tor-commits@lists.torproject.org