Skip to content

Commit

Permalink
Tidy up TestMultipleTorrentsWithEncryption test
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Sep 21, 2016
1 parent 7856cc6 commit 0c9c3d3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math/rand"
"net"
"os"
"path/filepath"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -1025,15 +1026,14 @@ func TestSetMaxEstablishedConn(t *testing.T) {
}

func makeMagnet(t *testing.T, cl *Client, dir string, name string) string {
var err error
file, err := os.Create(dir + "/" + name)
file, err := os.Create(filepath.Join(dir, name))
require.NoError(t, err)
file.Write([]byte(name))
file.Close()
mi := metainfo.MetaInfo{}
mi.SetDefaults()
info := metainfo.Info{PieceLength: 256 * 1024}
err = info.BuildFromFilePath(dir + "/" + name)
err = info.BuildFromFilePath(filepath.Join(dir, name))
require.NoError(t, err)
mi.InfoBytes, err = bencode.Marshal(info)
require.NoError(t, err)
Expand All @@ -1049,23 +1049,25 @@ func TestMultipleTorrentsWithEncryption(t *testing.T) {
cfg := TestingConfig
cfg.DisableUTP = true
cfg.Seed = true
cfg.DataDir = cfg.DataDir + "/server"
cfg.DataDir = filepath.Join(cfg.DataDir, "server")
cfg.Debug = true
cfg.ForceEncryption = true
os.Mkdir(cfg.DataDir, 0755)
server, err := NewClient(&cfg)
defer server.Close()
require.NoError(t, err)
defer server.Close()
testutil.ExportStatusWriter(server, "s")
magnet1 := makeMagnet(t, server, cfg.DataDir, "test1")
makeMagnet(t, server, cfg.DataDir, "test2")
cfg = TestingConfig
cfg.DisableUTP = true
cfg.DataDir = cfg.DataDir + "/client"
cfg.DataDir = filepath.Join(cfg.DataDir, "client")
cfg.Debug = true
cfg.ForceEncryption = true
client, err := NewClient(&cfg)
require.NoError(t, err)
defer client.Close()
testutil.ExportStatusWriter(client, "c")
tr, err := client.AddMagnet(magnet1)
require.NoError(t, err)
tr.AddPeers([]Peer{Peer{
Expand Down

0 comments on commit 0c9c3d3

Please sign in to comment.