(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func TestReadPacketWrongSequenceID(t *testing.T) { |
| 135 | for _, testCase := range []struct { |
| 136 | ClientSequenceID byte |
| 137 | ServerSequenceID byte |
| 138 | ExpectedErr error |
| 139 | }{ |
| 140 | { |
| 141 | ClientSequenceID: 1, |
| 142 | ServerSequenceID: 0, |
| 143 | ExpectedErr: ErrPktSync, |
| 144 | }, |
| 145 | { |
| 146 | ClientSequenceID: 0, |
| 147 | ServerSequenceID: 0x42, |
| 148 | ExpectedErr: ErrPktSync, |
| 149 | }, |
| 150 | } { |
| 151 | conn, mc := newRWMockConn(testCase.ClientSequenceID) |
| 152 | |
| 153 | conn.data = []byte{0x01, 0x00, 0x00, testCase.ServerSequenceID, 0x22} |
| 154 | _, err := mc.readPacket() |
| 155 | if err != testCase.ExpectedErr { |
| 156 | t.Errorf("expected %v, got %v", testCase.ExpectedErr, err) |
| 157 | } |
| 158 | |
| 159 | // connection should not be returned to the pool in this state |
| 160 | if mc.IsValid() { |
| 161 | t.Errorf("expected IsValid() to be false") |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func TestReadPacketSplit(t *testing.T) { |
| 167 | conn := new(mockConn) |
nothing calls this directly
no test coverage detected