]> Sergey Matveev's repositories - btrtrc.git/blobdiff - testing.go
Drop support for go 1.20
[btrtrc.git] / testing.go
index facf68a97a70e9ab03d1a83a1489c766185f925f..6fb5411267e8c486d454ba384d823f59e9ccc6bd 100644 (file)
@@ -1,20 +1,29 @@
 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.WithContextText(t.Name())
+       // 2 would suffice for the greeting test, but 5 is needed for a few other tests. This should be
+       // something slightly higher than the usual chunk size, so it gets tickled in some tests.
+       cfg.MaxAllocPeerRequestDataPerConn = 5
        //cfg.Debug = true
        //cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
        //      t := m.Text()