]> Sergey Matveev's repositories - btrtrc.git/blob - testing.go
Drop support for go 1.20
[btrtrc.git] / testing.go
1 package torrent
2
3 import (
4         "testing"
5         "time"
6
7         "github.com/anacrolix/log"
8
9         pp "github.com/anacrolix/torrent/peer_protocol"
10 )
11
12 func TestingConfig(t testing.TB) *ClientConfig {
13         cfg := NewDefaultClientConfig()
14         cfg.ListenHost = LoopbackListenHost
15         cfg.NoDHT = true
16         cfg.DataDir = t.TempDir()
17         cfg.DisableTrackers = true
18         cfg.NoDefaultPortForwarding = true
19         cfg.DisableAcceptRateLimiting = true
20         cfg.ListenPort = 0
21         cfg.KeepAliveTimeout = time.Millisecond
22         cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
23         cfg.Logger = log.Default.WithContextText(t.Name())
24         // 2 would suffice for the greeting test, but 5 is needed for a few other tests. This should be
25         // something slightly higher than the usual chunk size, so it gets tickled in some tests.
26         cfg.MaxAllocPeerRequestDataPerConn = 5
27         //cfg.Debug = true
28         //cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
29         //      t := m.Text()
30         //      m.Values(func(i interface{}) bool {
31         //              t += fmt.Sprintf("\n%[1]T: %[1]v", i)
32         //              return true
33         //      })
34         //      return t
35         //})
36         return cfg
37 }