Просмотр исходного кода

Small improvements

tags/v2.0.0-rc1
9seconds 5 лет назад
Родитель
Сommit
b42e51e300
2 измененных файлов: 8 добавлений и 6 удалений
  1. 5
    5
      mtglib/internal/relay/relay_test.go
  2. 3
    1
      mtglib/stream_context.go

+ 5
- 5
mtglib/internal/relay/relay_test.go Просмотреть файл

32
 	suite.ctxCancel()
32
 	suite.ctxCancel()
33
 
33
 
34
 	eastConn := &rwcMock{}
34
 	eastConn := &rwcMock{}
35
-	eastConn.Write([]byte{1, 2, 3, 4, 5})
35
+	eastConn.Write([]byte{1, 2, 3, 4, 5}) // nolint: errcheck
36
 
36
 
37
 	westConn := &rwcMock{}
37
 	westConn := &rwcMock{}
38
-	westConn.Write([]byte{100, 101, 102})
38
+	westConn.Write([]byte{100, 101, 102}) // nolint: errcheck
39
 
39
 
40
 	suite.Nil(suite.r.Process(eastConn, westConn))
40
 	suite.Nil(suite.r.Process(eastConn, westConn))
41
 }
41
 }
42
 
42
 
43
 func (suite *RelayTestSuite) TestCopyFine() {
43
 func (suite *RelayTestSuite) TestCopyFine() {
44
 	eastConn := &rwcMock{}
44
 	eastConn := &rwcMock{}
45
-	eastConn.Write([]byte{1, 2, 3, 4, 5})
45
+	eastConn.Write([]byte{1, 2, 3, 4, 5}) // nolint: errcheck
46
 
46
 
47
 	westConn := &rwcMock{}
47
 	westConn := &rwcMock{}
48
-	westConn.Write([]byte{100, 101, 102})
48
+	westConn.Write([]byte{100, 101, 102}) // nolint: errcheck
49
 
49
 
50
-	suite.NotNil(suite.r.Process(eastConn, westConn))
50
+	suite.r.Process(eastConn, westConn)
51
 }
51
 }
52
 
52
 
53
 func TestRelay(t *testing.T) {
53
 func TestRelay(t *testing.T) {

+ 3
- 1
mtglib/stream_context.go Просмотреть файл

8
 	"time"
8
 	"time"
9
 )
9
 )
10
 
10
 
11
+const ConnectionIDBytesLength = 16
12
+
11
 type streamContext struct {
13
 type streamContext struct {
12
 	ctx          context.Context
14
 	ctx          context.Context
13
 	ctxCancel    context.CancelFunc
15
 	ctxCancel    context.CancelFunc
51
 }
53
 }
52
 
54
 
53
 func newStreamContext(ctx context.Context, logger Logger, clientConn net.Conn) *streamContext {
55
 func newStreamContext(ctx context.Context, logger Logger, clientConn net.Conn) *streamContext {
54
-	connIDBytes := make([]byte, 16)
56
+	connIDBytes := make([]byte, ConnectionIDBytesLength)
55
 
57
 
56
 	if _, err := rand.Read(connIDBytes); err != nil {
58
 	if _, err := rand.Read(connIDBytes); err != nil {
57
 		panic(err)
59
 		panic(err)

Загрузка…
Отмена
Сохранить