]> Sergey Matveev's repositories - btrtrc.git/blob - testing.go
Make use of the lazylog branch of anacrolix/log
[btrtrc.git] / testing.go
1 package torrent
2
3 import (
4         "testing"
5         "time"
6
7         "github.com/anacrolix/log"
8         pp "github.com/anacrolix/torrent/peer_protocol"
9 )
10
11 func TestingConfig(t testing.TB) *ClientConfig {
12         cfg := NewDefaultClientConfig()
13         cfg.ListenHost = LoopbackListenHost
14         cfg.NoDHT = true
15         cfg.DataDir = t.TempDir()
16         cfg.DisableTrackers = true
17         cfg.NoDefaultPortForwarding = true
18         cfg.DisableAcceptRateLimiting = true
19         cfg.ListenPort = 0
20         cfg.KeepAliveTimeout = time.Millisecond
21         cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
22         cfg.Logger = log.Default.WithNames(t.Name())
23         //cfg.Debug = true
24         //cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
25         //      t := m.Text()
26         //      m.Values(func(i interface{}) bool {
27         //              t += fmt.Sprintf("\n%[1]T: %[1]v", i)
28         //              return true
29         //      })
30         //      return t
31         //})
32         return cfg
33 }