projects
/
btrtrc.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eb29dce
)
mse: Check that readUntil doesn't read indefinitely while synchronizing
author
Matt Joiner <anacrolix@gmail.com>
Wed, 18 Mar 2015 07:16:27 +0000 (18:16 +1100)
committer
Matt Joiner <anacrolix@gmail.com>
Wed, 18 Mar 2015 07:16:27 +0000 (18:16 +1100)
mse/mse_test.go
patch
|
blob
|
history
diff --git
a/mse/mse_test.go
b/mse/mse_test.go
index 6b5f82c39fba997bdfb68c536c2c5194b5ec2649..bc14c168147c90c7e2c3f8b7dc7bee1c6819f465 100644
(file)
--- a/
mse/mse_test.go
+++ b/
mse/mse_test.go
@@
-2,7
+2,9
@@
package mse
import (
"bytes"
+ "crypto/rand"
"io"
+ "io/ioutil"
"net"
"sync"
@@
-102,3
+104,19
@@
func BenchmarkHandshake(b *testing.B) {
allHandshakeTests(b)
}
}
+
+type trackReader struct {
+ r io.Reader
+ n int64
+}
+
+func (me *trackReader) Read(b []byte) (n int, err error) {
+ n, err = me.r.Read(b)
+ me.n += int64(n)
+ return
+}
+
+func TestReceiveRandomData(t *testing.T) {
+ tr := trackReader{rand.Reader, 0}
+ ReceiveHandshake(readWriter{&tr, ioutil.Discard}, nil)
+}