]> Sergey Matveev's repositories - btrtrc.git/blobdiff - testing.go
Add holepunching stats and tests
[btrtrc.git] / testing.go
index facf68a97a70e9ab03d1a83a1489c766185f925f..1df8abc0d34b09333906c142e3aecc7586eada1e 100644 (file)
@@ -1,20 +1,26 @@
 package torrent
 
 import (
-       "github.com/anacrolix/torrent/internal/tmproot"
-)
+       "testing"
+       "time"
+
+       "github.com/anacrolix/log"
 
-var TestingTempDir tmproot.Dir
+       pp "github.com/anacrolix/torrent/peer_protocol"
+)
 
-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
        cfg.ListenPort = 0
+       cfg.KeepAliveTimeout = time.Millisecond
+       cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
+       cfg.Logger = log.Default.WithNames(t.Name())
        //cfg.Debug = true
        //cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
        //      t := m.Text()