You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: client_e2e_test.go
    path of file: ./repos/td/telegram
    
    the code of the file until where you have to start completion: package telegram_test

import (
	"bytes"
	"context"
	"testing"
	"time"

	"github.com/go-faster/errors"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"go.uber.org/zap"
	"go.uber.org/zap/zaptest"

	"github.com/gotd/td/session"
	"github.com/gotd/td/tdsync"
	"github.com/gotd/td/telegram"
	"github.com/gotd/td/telegram/dcs"
	"github.com/gotd/td/telegram/downloader"
	"github.com/gotd/td/telegram/uploader"
	"github.com/gotd/td/tg"
	"github.com/gotd/td/tgerr"
	"github.com/gotd/td/tgtest"
	"github.com/gotd/td/tgtest/cluster"
	"github.com/gotd/td/tgtest/services/file"
	"github.com/gotd/td/transport"
)

type clusterSetup struct {
	TB      testing.TB
	Cluster *cluster.Cluster
	Logger  *zap.Logger
}

type clientSetup struct {
	TB       testing.TB
	Options  telegram.Options
	Complete func()
}

var user = &tg.User{
	ID:         10,
	AccessHash: 10,
	Username:   "username",
}

func testCluster(
	p dcs.Protocol,
	ws bool,
	setup func(q clusterSetup),
	run func(ctx context.Context, c clientSetup) error,
) func(t *testing.T) {
	return func(t *testing.T) {
		t.Parallel()

		log := zaptest.NewLogger(t)
		defer func() { _ = log.Sync() }()

		ctx, cancel := context.WithTimeout(cont
    
func testFiles(p dcs.Protocol) func(t *testing.T) {
	test := func(ws bool) func(t *testing.T) {
		return testCluster(p, ws, func(s clusterSetup) {
			c := s.Cluster
			c.Common().Vector(tg.UsersGetUsersRequestTypeID, user)
			f := file.NewService(file.Config{
				HashPartSize: 1024,
			})
			f.Register(c.Dispatch(2, "DC"))
		}, func(ctx context.Context, c clientSetup) error {
			client := telegram.NewClient(1, "hash", c.Options)
			defer c.Complete()
			return client.Run(ctx, func(ctx context.Context) error {
				raw := tg.NewClient(client)
				upd := uploader.NewUploader(raw)
				dwn := downloader.NewDownloader()

				payloads := [][]byte{
					[]byte("data"),
					bytes.Repeat([]byte{10}, 1337),
					bytes.Repeat([]byte{42}, 16384),
				}

				for _, payload := range payloads {
					f, err := upd.FromBytes(ctx, "10.jpg", payload)
					if err != nil {
						return err
					}

					var b bytes.Buffer
					_, err = dwn.Download(raw, &tg.InputFileLocation{
						VolumeID: f.GetID(),
						LocalID:  10,
					}).WithVerify(true).Stream(ctx, &b)
					if err != nil {
						return err
					}

					if !bytes.Equal(payload, b.Bytes()) {
						c.TB.Error("must be equal")
					}
				}
				return nil
			})
		})
	}

	return func(t *testing.T) {
		t.Run("TCP", test(false))
		t.Run("Websocket", test(true))
	}
}