summaryrefslogtreecommitdiffhomepage
path: root/server/fsm_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/fsm_test.go')
-rw-r--r--server/fsm_test.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/server/fsm_test.go b/server/fsm_test.go
index 7e321787..8c40d81c 100644
--- a/server/fsm_test.go
+++ b/server/fsm_test.go
@@ -65,25 +65,19 @@ func (m *MockConnection) Read(buf []byte) (int, error) {
m.currentCh = <-m.recvCh
}
- rest := len(buf) - m.readBytes
+ length := 0
+ rest := len(buf)
for i := 0; i < rest; i++ {
if len(m.currentCh) > 0 {
val := <-m.currentCh
- buf[m.readBytes] = val
- m.readBytes += 1
+ buf[i] = val
+ length++
} else {
m.currentCh = nil
break
}
}
- length := 0
- if m.readBytes == len(buf) {
- m.readBytes = 0
- length = len(buf)
- } else {
- length = m.readBytes
- }
fmt.Printf("%d bytes read from peer\n", length)
return length, nil
}