@@ -21,19 +21,9 @@ func TestWriteMsgLen(t *testing.T) {
21
21
expectedErr error
22
22
}{
23
23
{
24
- msgLen : math .MaxUint32 ,
25
- msgLimit : math .MaxUint32 ,
26
- expectedErr : errInvalidMaxMessageLength ,
27
- },
28
- {
29
- msgLen : bitmaskCodec ,
30
- msgLimit : bitmaskCodec ,
31
- expectedErr : errInvalidMaxMessageLength ,
32
- },
33
- {
34
- msgLen : bitmaskCodec - 1 ,
35
- msgLimit : bitmaskCodec - 1 ,
36
- expectedErr : nil ,
24
+ msgLen : constants .DefaultMaxMessageSize ,
25
+ msgLimit : 1 ,
26
+ expectedErr : errMaxMessageLengthExceeded ,
37
27
},
38
28
{
39
29
msgLen : constants .DefaultMaxMessageSize ,
@@ -45,11 +35,6 @@ func TestWriteMsgLen(t *testing.T) {
45
35
msgLimit : constants .DefaultMaxMessageSize ,
46
36
expectedErr : nil ,
47
37
},
48
- {
49
- msgLen : constants .DefaultMaxMessageSize ,
50
- msgLimit : 1 ,
51
- expectedErr : errMaxMessageLengthExceeded ,
52
- },
53
38
}
54
39
for _ , tv := range tt {
55
40
msgLenBytes , err := writeMsgLen (tv .msgLen , tv .msgLimit )
@@ -73,39 +58,27 @@ func TestReadMsgLen(t *testing.T) {
73
58
expectedErr error
74
59
expectedMsgLen uint32
75
60
}{
76
- {
77
- msgLenBytes : []byte {0xFF , 0xFF , 0xFF , 0xFF },
78
- msgLimit : math .MaxUint32 ,
79
- expectedErr : errInvalidMaxMessageLength ,
80
- expectedMsgLen : 0 ,
81
- },
82
61
{
83
62
msgLenBytes : []byte {0b11111111 , 0xFF },
84
63
msgLimit : math .MaxInt32 ,
85
64
expectedErr : errInvalidMessageLength ,
86
65
expectedMsgLen : 0 ,
87
66
},
88
67
{
89
- msgLenBytes : []byte {0b11111111 , 0xFF , 0xFF , 0xFF },
68
+ msgLenBytes : []byte {0xFF , 0xFF , 0xFF , 0xFF },
90
69
msgLimit : constants .DefaultMaxMessageSize ,
91
70
expectedErr : errMaxMessageLengthExceeded ,
92
71
expectedMsgLen : 0 ,
93
72
},
94
73
{
95
- msgLenBytes : []byte {0b11111111 , 0xFF , 0xFF , 0xFF },
96
- msgLimit : math .MaxInt32 ,
97
- expectedErr : nil ,
98
- expectedMsgLen : math .MaxInt32 ,
99
- },
100
- {
101
- msgLenBytes : []byte {0b10000000 , 0x00 , 0x00 , 0x01 },
102
- msgLimit : math .MaxInt32 ,
74
+ msgLenBytes : []byte {0xFF , 0xFF , 0xFF , 0xFF },
75
+ msgLimit : math .MaxUint32 ,
103
76
expectedErr : nil ,
104
- expectedMsgLen : 1 ,
77
+ expectedMsgLen : math . MaxUint32 ,
105
78
},
106
79
{
107
- msgLenBytes : []byte {0b10000000 , 0x00 , 0x00 , 0x01 },
108
- msgLimit : 1 ,
80
+ msgLenBytes : []byte {0x00 , 0x00 , 0x00 , 0x01 },
81
+ msgLimit : 10 ,
109
82
expectedErr : nil ,
110
83
expectedMsgLen : 1 ,
111
84
},
@@ -126,34 +99,3 @@ func TestReadMsgLen(t *testing.T) {
126
99
require .Equal (tv .expectedMsgLen , msgLenAfterWrite )
127
100
}
128
101
}
129
-
130
- func TestBackwardsCompatibleReadMsgLen (t * testing.T ) {
131
- require := require .New (t )
132
-
133
- tt := []struct {
134
- msgLenBytes []byte
135
- msgLimit uint32
136
- expectedMsgLen uint32
137
- }{
138
- {
139
- msgLenBytes : []byte {0b01111111 , 0xFF , 0xFF , 0xFF },
140
- msgLimit : math .MaxInt32 ,
141
- expectedMsgLen : math .MaxInt32 ,
142
- },
143
- {
144
- msgLenBytes : []byte {0b00000000 , 0x00 , 0x00 , 0x01 },
145
- msgLimit : math .MaxInt32 ,
146
- expectedMsgLen : 1 ,
147
- },
148
- {
149
- msgLenBytes : []byte {0b00000000 , 0x00 , 0x00 , 0x01 },
150
- msgLimit : 1 ,
151
- expectedMsgLen : 1 ,
152
- },
153
- }
154
- for _ , tv := range tt {
155
- msgLen , err := readMsgLen (tv .msgLenBytes , tv .msgLimit )
156
- require .NoError (err )
157
- require .Equal (tv .expectedMsgLen , msgLen )
158
- }
159
- }
0 commit comments