2
0
mirror of synced 2025-02-23 14:18:13 +00:00
torrent/testing.go

35 lines
802 B
Go
Raw Normal View History

package torrent
import (
"testing"
"time"
2021-10-25 20:52:44 +11:00
"github.com/anacrolix/log"
2022-11-15 23:22:10 +11:00
2021-10-25 20:52:44 +11:00
pp "github.com/anacrolix/torrent/peer_protocol"
)
func TestingConfig(t testing.TB) *ClientConfig {
cfg := NewDefaultClientConfig()
cfg.ListenHost = LoopbackListenHost
cfg.NoDHT = true
cfg.DataDir = t.TempDir()
cfg.DisableTrackers = true
cfg.NoDefaultPortForwarding = true
cfg.DisableAcceptRateLimiting = true
cfg.ListenPort = 0
cfg.KeepAliveTimeout = time.Millisecond
2021-10-25 20:52:44 +11:00
cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
2023-05-18 21:25:44 +10:00
cfg.Logger = log.Default.WithContextText(t.Name())
//cfg.Debug = true
//cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
// t := m.Text()
// m.Values(func(i interface{}) bool {
// t += fmt.Sprintf("\n%[1]T: %[1]v", i)
// return true
// })
// return t
//})
return cfg
}