TestLargeRecord writes a very large ALTS record and verifies that the server receives it correctly. The large ALTS record should cause the reader to expand it's read buffer to hold the entire record and store the decrypted message until the receiver reads all of the bytes.
(t *testing.T)
| 194 | // expand it's read buffer to hold the entire record and store the decrypted |
| 195 | // message until the receiver reads all of the bytes. |
| 196 | func (s) TestLargeRecord(t *testing.T) { |
| 197 | clientConn, serverConn := newConnPair(rekeyRecordProtocol, nil, nil) |
| 198 | msg := []byte(strings.Repeat("a", 2*altsReadBufferInitialSize)) |
| 199 | // Increase the size of ALTS records written by the client. |
| 200 | clientConn.payloadLengthLimit = math.MaxInt32 |
| 201 | if n, err := clientConn.Write(msg); n != len(msg) || err != nil { |
| 202 | t.Fatalf("Write() = %v, %v; want %v, <nil>", n, err, len(msg)) |
| 203 | } |
| 204 | rcvMsg := make([]byte, len(msg)) |
| 205 | if n, err := io.ReadFull(serverConn, rcvMsg); n != len(rcvMsg) || err != nil { |
| 206 | t.Fatalf("Read() = %v, %v; want %v, <nil>", n, err, len(rcvMsg)) |
| 207 | } |
| 208 | if !reflect.DeepEqual(msg, rcvMsg) { |
| 209 | t.Fatalf("Write()/Server Read() = %v, want %v", rcvMsg, msg) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // BenchmarkLargeMessage measures the performance of ALTS conns for sending and |
| 214 | // receiving a large message. |
nothing calls this directly
no test coverage detected