connection_test.go 459 B

123456789101112131415161718192021
  1. package kcp_test
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/v2ray/v2ray-core/testing/assert"
  6. . "github.com/v2ray/v2ray-core/transport/internet/kcp"
  7. )
  8. func TestConnectionReadTimeout(t *testing.T) {
  9. assert := assert.On(t)
  10. conn := NewConnection(1, nil, nil, nil, NewSimpleAuthenticator())
  11. conn.SetReadDeadline(time.Now().Add(time.Second))
  12. b := make([]byte, 1024)
  13. nBytes, err := conn.Read(b)
  14. assert.Int(nBytes).Equals(0)
  15. assert.Error(err).IsNotNil()
  16. }