]> Sergey Matveev's repositories - btrtrc.git/blob - testing.go
Include PeerConn prefix for log messages
[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.WithNames(t.Name())
24         //cfg.Debug = true
25         //cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
26         //      t := m.Text()
27         //      m.Values(func(i interface{}) bool {
28         //              t += fmt.Sprintf("\n%[1]T: %[1]v", i)
29         //              return true
30         //      })
31         //      return t
32         //})
33         return cfg
34 }