(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestCoordinateResponse_Chunked(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | |
| 14 | t.Run("NoChunkingNeeded", func(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | resp := &proto.CoordinateResponse{ |
| 17 | PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, 100), |
| 18 | } |
| 19 | chunks := resp.Chunked() |
| 20 | require.Len(t, chunks, 1) |
| 21 | require.Equal(t, resp, chunks[0]) |
| 22 | }) |
| 23 | |
| 24 | t.Run("ExactLimit", func(t *testing.T) { |
| 25 | t.Parallel() |
| 26 | resp := &proto.CoordinateResponse{ |
| 27 | PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, 1024), |
| 28 | } |
| 29 | chunks := resp.Chunked() |
| 30 | require.Len(t, chunks, 1) |
| 31 | require.Equal(t, resp, chunks[0]) |
| 32 | }) |
| 33 | |
| 34 | t.Run("MultipleChunks", func(t *testing.T) { |
| 35 | t.Parallel() |
| 36 | n := 1024*3 + 500 |
| 37 | resp := &proto.CoordinateResponse{ |
| 38 | PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, n), |
| 39 | } |
| 40 | chunks := resp.Chunked() |
| 41 | require.Len(t, chunks, 4) |
| 42 | total := 0 |
| 43 | for _, c := range chunks { |
| 44 | total += len(c.GetPeerUpdates()) |
| 45 | } |
| 46 | require.Equal(t, n, total) |
| 47 | }) |
| 48 | |
| 49 | t.Run("EmptyResponse", func(t *testing.T) { |
| 50 | t.Parallel() |
| 51 | resp := &proto.CoordinateResponse{} |
| 52 | chunks := resp.Chunked() |
| 53 | require.Len(t, chunks, 1) |
| 54 | }) |
| 55 | } |
nothing calls this directly
no test coverage detected