]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Replace internal/tmproot with Testing.TB.TempDir
authorMatt Joiner <anacrolix@gmail.com>
Mon, 22 Feb 2021 03:30:09 +0000 (14:30 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 22 Feb 2021 03:30:09 +0000 (14:30 +1100)
13 files changed:
client_test.go
internal/tmproot/dir.go [deleted file]
issue211_test.go
main_test.go
peerconn_test.go
pexconn_test.go
reader_test.go
test/init_test.go
test/issue377_test.go
test/transfer_test.go
test/unix_test.go
testing.go
torrent_test.go

index 6e7a8dad171c020d99348923496758d8859e0bc4..5abc83e4df4121d76d8d9ed6758d60eaffa44bda 100644 (file)
@@ -29,7 +29,7 @@ import (
 )
 
 func TestClientDefault(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        cl.Close()
 }
@@ -41,7 +41,7 @@ func TestClientNilConfig(t *testing.T) {
 }
 
 func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        pc, err := storage.NewBoltPieceCompletion(cfg.DataDir)
        require.NoError(t, err)
        ci := storage.NewFileWithCompletion(cfg.DataDir, pc)
@@ -57,7 +57,7 @@ func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
 }
 
 func TestAddDropTorrent(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        dir, mi := testutil.GreetingTestTorrent()
@@ -93,12 +93,12 @@ func TestTorrentInitialState(t *testing.T) {
        dir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(dir)
        cl := &Client{
-               config: TestingConfig(),
+               config: TestingConfig(t),
        }
        cl.initLogger()
        tor := cl.newTorrent(
                mi.HashInfoBytes(),
-               storage.NewFileWithCompletion(TestingTempDir.NewSub(), storage.NewMapPieceCompletion()),
+               storage.NewFileWithCompletion(t.TempDir(), storage.NewMapPieceCompletion()),
        )
        tor.setChunkSize(2)
        tor.cl.lock()
@@ -140,7 +140,7 @@ func TestReducedDialTimeout(t *testing.T) {
 }
 
 func TestAddDropManyTorrents(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        for i := range iter.N(1000) {
@@ -163,7 +163,7 @@ func fileCachePieceResourceStorage(fc *filecache.Cache) storage.ClientImpl {
 }
 
 func TestMergingTrackersByAddingSpecs(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        spec := TorrentSpec{}
@@ -181,7 +181,7 @@ func TestMergingTrackersByAddingSpecs(t *testing.T) {
 
 // We read from a piece which is marked completed, but is missing data.
 func TestCompletedPieceWrongSize(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DefaultStorage = badStorage{}
        cl, err := NewClient(cfg)
        require.NoError(t, err)
@@ -208,7 +208,7 @@ func TestCompletedPieceWrongSize(t *testing.T) {
 }
 
 func BenchmarkAddLargeTorrent(b *testing.B) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(b)
        cfg.DisableTCP = true
        cfg.DisableUTP = true
        cl, err := NewClient(cfg)
@@ -227,7 +227,7 @@ func BenchmarkAddLargeTorrent(b *testing.B) {
 func TestResponsive(t *testing.T) {
        seederDataDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(seederDataDir)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir = seederDataDir
        seeder, err := NewClient(cfg)
@@ -238,7 +238,7 @@ func TestResponsive(t *testing.T) {
        leecherDataDir, err := ioutil.TempDir("", "")
        require.Nil(t, err)
        defer os.RemoveAll(leecherDataDir)
-       cfg = TestingConfig()
+       cfg = TestingConfig(t)
        cfg.DataDir = leecherDataDir
        leecher, err := NewClient(cfg)
        require.Nil(t, err)
@@ -270,7 +270,7 @@ func TestResponsive(t *testing.T) {
 func TestTorrentDroppedDuringResponsiveRead(t *testing.T) {
        seederDataDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(seederDataDir)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir = seederDataDir
        seeder, err := NewClient(cfg)
@@ -281,7 +281,7 @@ func TestTorrentDroppedDuringResponsiveRead(t *testing.T) {
        leecherDataDir, err := ioutil.TempDir("", "")
        require.Nil(t, err)
        defer os.RemoveAll(leecherDataDir)
-       cfg = TestingConfig()
+       cfg = TestingConfig(t)
        cfg.DataDir = leecherDataDir
        leecher, err := NewClient(cfg)
        require.Nil(t, err)
@@ -313,7 +313,7 @@ func TestTorrentDroppedDuringResponsiveRead(t *testing.T) {
 func TestDhtInheritBlocklist(t *testing.T) {
        ipl := iplist.New(nil)
        require.NotNil(t, ipl)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.IPBlocklist = ipl
        cfg.NoDHT = false
        cl, err := NewClient(cfg)
@@ -331,7 +331,7 @@ func TestDhtInheritBlocklist(t *testing.T) {
 // Check that stuff is merged in subsequent AddTorrentSpec for the same
 // infohash.
 func TestAddTorrentSpecMerging(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        dir, mi := testutil.GreetingTestTorrent()
@@ -351,7 +351,7 @@ func TestAddTorrentSpecMerging(t *testing.T) {
 func TestTorrentDroppedBeforeGotInfo(t *testing.T) {
        dir, mi := testutil.GreetingTestTorrent()
        os.RemoveAll(dir)
-       cl, _ := NewClient(TestingConfig())
+       cl, _ := NewClient(TestingConfig(t))
        defer cl.Close()
        tt, _, _ := cl.AddTorrentSpec(&TorrentSpec{
                InfoHash: mi.HashInfoBytes(),
@@ -395,7 +395,7 @@ func testAddTorrentPriorPieceCompletion(t *testing.T, alreadyCompleted bool, csf
                        require.NoError(t, greetingData.Piece(p).MarkComplete())
                }
        }
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        // TODO: Disable network option?
        cfg.DisableTCP = true
        cfg.DisableUTP = true
@@ -424,7 +424,7 @@ func TestAddTorrentPiecesNotAlreadyCompleted(t *testing.T) {
 }
 
 func TestAddMetainfoWithNodes(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.ListenHost = func(string) string { return "" }
        cfg.NoDHT = false
        cfg.DhtStartingNodes = func(string) dht.StartingNodesGetter { return func() ([]dht.Addr, error) { return nil, nil } }
@@ -461,7 +461,7 @@ type testDownloadCancelParams struct {
 func testDownloadCancel(t *testing.T, ps testDownloadCancelParams) {
        greetingTempDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(greetingTempDir)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir = greetingTempDir
        seeder, err := NewClient(cfg)
@@ -530,7 +530,7 @@ func TestTorrentDownloadAllThenCancel(t *testing.T) {
 
 // Ensure that it's an error for a peer to send an invalid have message.
 func TestPeerInvalidHave(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DropMutuallyCompletePeers = false
        cl, err := NewClient(cfg)
        require.NoError(t, err)
@@ -561,9 +561,9 @@ func TestPeerInvalidHave(t *testing.T) {
 func TestPieceCompletedInStorageButNotClient(t *testing.T) {
        greetingTempDir, greetingMetainfo := testutil.GreetingTestTorrent()
        defer os.RemoveAll(greetingTempDir)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DataDir = greetingTempDir
-       seeder, err := NewClient(TestingConfig())
+       seeder, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        seeder.AddTorrentSpec(&TorrentSpec{
                InfoBytes: greetingMetainfo.InfoBytes,
@@ -573,7 +573,7 @@ func TestPieceCompletedInStorageButNotClient(t *testing.T) {
 // Check that when the listen port is 0, all the protocols listened on have
 // the same port, and it isn't zero.
 func TestClientDynamicListenPortAllProtocols(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        port := cl.LocalPort()
@@ -585,7 +585,7 @@ func TestClientDynamicListenPortAllProtocols(t *testing.T) {
 }
 
 func TestClientDynamicListenTCPOnly(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DisableUTP = true
        cfg.DisableTCP = false
        cl, err := NewClient(cfg)
@@ -595,7 +595,7 @@ func TestClientDynamicListenTCPOnly(t *testing.T) {
 }
 
 func TestClientDynamicListenUTPOnly(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DisableTCP = true
        cfg.DisableUTP = false
        cl, err := NewClient(cfg)
@@ -616,7 +616,7 @@ func totalConns(tts []*Torrent) (ret int) {
 func TestSetMaxEstablishedConn(t *testing.T) {
        var tts []*Torrent
        ih := testutil.GreetingMetaInfo().HashInfoBytes()
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DisableAcceptRateLimiting = true
        cfg.DropDuplicatePeerIds = true
        for i := range iter.N(3) {
@@ -697,7 +697,7 @@ func TestMultipleTorrentsWithEncryption(t *testing.T) {
 // Test that the leecher can download a torrent in its entirety from the seeder. Note that the
 // seeder config is done first.
 func testSeederLeecherPair(t *testing.T, seeder func(*ClientConfig), leecher func(*ClientConfig)) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir = filepath.Join(cfg.DataDir, "server")
        os.Mkdir(cfg.DataDir, 0755)
@@ -713,7 +713,7 @@ func testSeederLeecherPair(t *testing.T, seeder func(*ClientConfig), leecher fun
        for i := 0; i < 100; i++ {
                makeMagnet(t, server, cfg.DataDir, fmt.Sprintf("test%d", i+2))
        }
-       cfg = TestingConfig()
+       cfg = TestingConfig(t)
        cfg.DataDir = filepath.Join(cfg.DataDir, "client")
        leecher(cfg)
        client, err := NewClient(cfg)
@@ -764,14 +764,14 @@ func TestClientAddressInUse(t *testing.T) {
        if s != nil {
                defer s.Close()
        }
-       cfg := TestingConfig().SetListenAddr(":50007")
+       cfg := TestingConfig(t).SetListenAddr(":50007")
        cl, err := NewClient(cfg)
        require.Error(t, err)
        require.Nil(t, cl)
 }
 
 func TestClientHasDhtServersWhenUtpDisabled(t *testing.T) {
-       cc := TestingConfig()
+       cc := TestingConfig(t)
        cc.DisableUTP = true
        cc.NoDHT = false
        cl, err := NewClient(cc)
@@ -783,7 +783,7 @@ func TestClientHasDhtServersWhenUtpDisabled(t *testing.T) {
 func TestIssue335(t *testing.T) {
        dir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(dir)
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Seed = false
        cfg.Debug = true
        cfg.DataDir = dir
@@ -806,7 +806,7 @@ func TestIssue335(t *testing.T) {
 }
 
 func TestClientDisabledImplicitNetworksButDhtEnabled(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.DisableTCP = true
        cfg.DisableUTP = true
        cfg.NoDHT = false
diff --git a/internal/tmproot/dir.go b/internal/tmproot/dir.go
deleted file mode 100644 (file)
index 1e07866..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package tmproot
-
-import (
-       "io/ioutil"
-       "os"
-       "sync"
-)
-
-type Dir struct {
-       mu     sync.Mutex
-       path   string
-       inited bool
-}
-
-func (me *Dir) init(prefix string) bool {
-       if me.inited {
-               return false
-       }
-       var err error
-       me.path, err = ioutil.TempDir("", prefix)
-       if err != nil {
-               panic(err)
-       }
-       me.inited = true
-       return true
-}
-
-func (me *Dir) Init(prefix string) {
-       me.mu.Lock()
-       defer me.mu.Unlock()
-       if me.inited {
-               panic("already inited")
-       }
-       me.init(prefix)
-}
-
-func (me *Dir) lazyDefaultInit() {
-       me.mu.Lock()
-       defer me.mu.Unlock()
-       me.init("")
-
-}
-
-func (me *Dir) NewSub() string {
-       me.lazyDefaultInit()
-       ret, err := ioutil.TempDir(me.path, "")
-       if err != nil {
-               panic(err)
-       }
-       return ret
-}
-
-func (me *Dir) RemoveAll() error {
-       me.lazyDefaultInit()
-       return os.RemoveAll(me.path)
-}
index dedbaa5647a80a1337f94e10a7ef3aa38a2852b1..f33057e413972ee966c47fdb5e38cfe5346e6afc 100644 (file)
@@ -14,7 +14,7 @@ import (
 )
 
 func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        // Ensure the data is present when the torrent is added, and not obtained
        // over the network as the test runs.
        cfg.DownloadRateLimiter = rate.NewLimiter(0, 0)
index 301502c84a3c5f629760553eb13d2ff3d3b0b61c..51af26a041374468d11efece53c88b61999942e4 100644 (file)
@@ -13,9 +13,7 @@ func init() {
 }
 
 func TestMain(m *testing.M) {
-       TestingTempDir.Init("torrent.test")
        code := m.Run()
-       TestingTempDir.RemoveAll()
        // select {}
        os.Exit(code)
 }
index 654f7689fcd1d9fc105e14ff34d6e02e53be5066..7057e77dc9c3a1900c3a0356ec3939304fd5ded1 100644 (file)
@@ -21,7 +21,7 @@ import (
 // Have that would potentially alter it.
 func TestSendBitfieldThenHave(t *testing.T) {
        cl := Client{
-               config: TestingConfig(),
+               config: TestingConfig(t),
        }
        cl.initLogger()
        c := cl.newConnection(nil, false, nil, "io.Pipe", "")
index 609e088eee0dd21d1d877614497ef8e32112dc7b..0b78b70242f503605edb095db5112dcd751c3974 100644 (file)
@@ -13,7 +13,7 @@ import (
 
 func TestPexConnState(t *testing.T) {
        cl := Client{
-               config: TestingConfig(),
+               config: TestingConfig(t),
        }
        cl.initLogger()
        torrent := cl.newTorrent(metainfo.Hash{}, nil)
index 86021dd60ae8c6bfff8af2a93c04ec7d49014483..c1017a0cb8af6488d8a037312f31b3be84125fb7 100644 (file)
@@ -11,7 +11,7 @@ import (
 )
 
 func TestReaderReadContext(t *testing.T) {
-       cl, err := NewClient(TestingConfig())
+       cl, err := NewClient(TestingConfig(t))
        require.NoError(t, err)
        defer cl.Close()
        tt, err := cl.AddTorrent(testutil.GreetingMetaInfo())
index 9e63ef83cba7ba92f1df9fea88138b9823bc4ff3..38335ef8c6391f9144d98300d04ea0a912c41e12 100644 (file)
@@ -2,9 +2,4 @@ package test
 
 import (
        _ "github.com/anacrolix/envpprof"
-       "github.com/anacrolix/torrent"
 )
-
-func init() {
-       torrent.TestingTempDir.Init("torrent-test.test")
-}
index 4ede3576293f3d878b303e22180f1cac2dd906cb..bd8c4357d5a5e5e9366266fec633184791e8207f 100644 (file)
@@ -36,7 +36,7 @@ func TestReceiveChunkStorageFailure(t *testing.T) {
 func testReceiveChunkStorageFailure(t *testing.T, seederFast bool) {
        seederDataDir, metainfo := testutil.GreetingTestTorrent()
        defer os.RemoveAll(seederDataDir)
-       seederClientConfig := torrent.TestingConfig()
+       seederClientConfig := torrent.TestingConfig(t)
        seederClientConfig.Debug = true
        justOneNetwork(seederClientConfig)
        seederClientStorage := storage.NewMMap(seederDataDir)
@@ -49,7 +49,7 @@ func testReceiveChunkStorageFailure(t *testing.T, seederFast bool) {
        require.NoError(t, err)
        defer seederClient.Close()
        defer testutil.ExportStatusWriter(seederClient, "s", t)()
-       leecherClientConfig := torrent.TestingConfig()
+       leecherClientConfig := torrent.TestingConfig(t)
        leecherClientConfig.Debug = true
        justOneNetwork(leecherClientConfig)
        leecherClient, err := torrent.NewClient(leecherClientConfig)
index 47efef0bb3a90fefbbaff96324a9c48a8c09e8eb..f232b186ee7ce495b25af720366c432625f76945 100644 (file)
@@ -62,7 +62,7 @@ func testClientTransfer(t *testing.T, ps testClientTransferParams) {
        greetingTempDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(greetingTempDir)
        // Create seeder and a Torrent.
-       cfg := torrent.TestingConfig()
+       cfg := torrent.TestingConfig(t)
        cfg.Seed = true
        // Some test instances don't like this being on, even when there's no cache involved.
        cfg.DropMutuallyCompletePeers = false
@@ -96,7 +96,7 @@ func testClientTransfer(t *testing.T, ps testClientTransferParams) {
        leecherDataDir, err := ioutil.TempDir("", "")
        require.NoError(t, err)
        defer os.RemoveAll(leecherDataDir)
-       cfg = torrent.TestingConfig()
+       cfg = torrent.TestingConfig(t)
        // See the seeder client config comment.
        cfg.DropMutuallyCompletePeers = false
        if ps.LeecherStorage == nil {
@@ -388,7 +388,7 @@ func TestSeedAfterDownloading(t *testing.T) {
        greetingTempDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(greetingTempDir)
 
-       cfg := torrent.TestingConfig()
+       cfg := torrent.TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir = greetingTempDir
        seeder, err := torrent.NewClient(cfg)
@@ -400,7 +400,7 @@ func TestSeedAfterDownloading(t *testing.T) {
        assert.True(t, ok)
        seederTorrent.VerifyData()
 
-       cfg = torrent.TestingConfig()
+       cfg = torrent.TestingConfig(t)
        cfg.Seed = true
        cfg.DataDir, err = ioutil.TempDir("", "")
        require.NoError(t, err)
@@ -410,7 +410,7 @@ func TestSeedAfterDownloading(t *testing.T) {
        defer leecher.Close()
        defer testutil.ExportStatusWriter(leecher, "l", t)()
 
-       cfg = torrent.TestingConfig()
+       cfg = torrent.TestingConfig(t)
        cfg.Seed = false
        cfg.DataDir, err = ioutil.TempDir("", "")
        require.NoError(t, err)
index d021b985918fea99aeee070d5ff86368da89f612..1e877c0d5a9dd98c15dfb1daa756919fb955c7d2 100644 (file)
@@ -25,7 +25,7 @@ func TestUnixConns(t *testing.T) {
                },
                Client: func(cl *torrent.Client) {
                        cl.AddDialer(torrent.NetDialer{Network: "unix"})
-                       l, err := net.Listen("unix", filepath.Join(torrent.TestingTempDir.NewSub(), "socket"))
+                       l, err := net.Listen("unix", filepath.Join(t.TempDir(), "socket"))
                        if err != nil {
                                panic(err)
                        }
index facf68a97a70e9ab03d1a83a1489c766185f925f..01e728578fb902fb0ab7325b906431fdd09a0452 100644 (file)
@@ -1,16 +1,14 @@
 package torrent
 
 import (
-       "github.com/anacrolix/torrent/internal/tmproot"
+       "testing"
 )
 
-var TestingTempDir tmproot.Dir
-
-func TestingConfig() *ClientConfig {
+func TestingConfig(t testing.TB) *ClientConfig {
        cfg := NewDefaultClientConfig()
        cfg.ListenHost = LoopbackListenHost
        cfg.NoDHT = true
-       cfg.DataDir = TestingTempDir.NewSub()
+       cfg.DataDir = t.TempDir()
        cfg.DisableTrackers = true
        cfg.NoDefaultPortForwarding = true
        cfg.DisableAcceptRateLimiting = true
index b40650391d2e7c01e0636ed959797f5be349b620..d53aa693a4b8f7a53ea9860691560889513a41ae 100644 (file)
@@ -81,7 +81,7 @@ func BenchmarkUpdatePiecePriorities(b *testing.B) {
                numPieces   = 13410
                pieceLength = 256 << 10
        )
-       cl := &Client{config: TestingConfig()}
+       cl := &Client{config: TestingConfig(b)}
        cl.initLogger()
        t := cl.newTorrent(metainfo.Hash{}, nil)
        require.NoError(b, t.setInfo(&metainfo.Info{
@@ -132,7 +132,7 @@ func testEmptyFilesAndZeroPieceLength(t *testing.T, cfg *ClientConfig) {
 }
 
 func TestEmptyFilesAndZeroPieceLengthWithFileStorage(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        ci := storage.NewFile(cfg.DataDir)
        defer ci.Close()
        cfg.DefaultStorage = ci
@@ -140,7 +140,7 @@ func TestEmptyFilesAndZeroPieceLengthWithFileStorage(t *testing.T) {
 }
 
 func TestEmptyFilesAndZeroPieceLengthWithMMapStorage(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        ci := storage.NewMMap(cfg.DataDir)
        defer ci.Close()
        cfg.DefaultStorage = ci
@@ -150,7 +150,7 @@ func TestEmptyFilesAndZeroPieceLengthWithMMapStorage(t *testing.T) {
 func TestPieceHashFailed(t *testing.T) {
        mi := testutil.GreetingMetaInfo()
        cl := new(Client)
-       cl.config = TestingConfig()
+       cl.config = TestingConfig(t)
        cl.initLogger()
        tt := cl.newTorrent(mi.HashInfoBytes(), badStorage{})
        tt.setChunkSize(2)
@@ -166,7 +166,7 @@ func TestPieceHashFailed(t *testing.T) {
 
 // Check the behaviour of Torrent.Metainfo when metadata is not completed.
 func TestTorrentMetainfoIncompleteMetadata(t *testing.T) {
-       cfg := TestingConfig()
+       cfg := TestingConfig(t)
        cfg.Debug = true
        cl, err := NewClient(cfg)
        require.NoError(t, err)