From: Matt Joiner Date: Tue, 2 Dec 2014 20:23:01 +0000 (-0600) Subject: Speed up tests, allow -short for some UDP tracker stuff X-Git-Tag: v1.0.0~1436 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c75f79b0978e8b88a248908d7cc9a7f64f730af3;p=btrtrc.git Speed up tests, allow -short for some UDP tracker stuff --- diff --git a/client.go b/client.go index 24af34da..5625f017 100644 --- a/client.go +++ b/client.go @@ -383,9 +383,11 @@ func NewClient(cfg *Config) (cl *Client, err error) { } cl.event.L = &cl.mu - err = cl.setEnvBlocklist() - if err != nil { - return + if !cfg.NoDefaultBlocklist { + err = cl.setEnvBlocklist() + if err != nil { + return + } } if err = cl.initBannedTorrents(); err != nil { diff --git a/client_test.go b/client_test.go index 207790df..e5ee79d2 100644 --- a/client_test.go +++ b/client_test.go @@ -11,7 +11,9 @@ import ( ) func TestClientDefault(t *testing.T) { - cl, err := NewClient(nil) + cl, err := NewClient(&Config{ + NoDefaultBlocklist: true, + }) if err != nil { t.Fatal(err) } diff --git a/config.go b/config.go index 9b1cae61..c78db5be 100644 --- a/config.go +++ b/config.go @@ -5,14 +5,15 @@ import ( ) type Config struct { - DataDir string - ListenAddr string - DisableTrackers bool - DownloadStrategy DownloadStrategy - NoDHT bool - DHTConfig *dht.ServerConfig - NoUpload bool - PeerID string - DisableUTP bool - DisableTCP bool + DataDir string + ListenAddr string + DisableTrackers bool + DownloadStrategy DownloadStrategy + NoDHT bool + DHTConfig *dht.ServerConfig + NoUpload bool + PeerID string + DisableUTP bool + DisableTCP bool + NoDefaultBlocklist bool } diff --git a/fs/torrentfs_test.go b/fs/torrentfs_test.go index 372b8f29..2f9c79fb 100644 --- a/fs/torrentfs_test.go +++ b/fs/torrentfs_test.go @@ -13,7 +13,6 @@ import ( "strconv" "strings" "testing" - "time" "bitbucket.org/anacrolix/go.torrent" "bitbucket.org/anacrolix/go.torrent/testutil" @@ -93,6 +92,8 @@ func TestUnmountWedged(t *testing.T) { DataDir: filepath.Join(layout.BaseDir, "incomplete"), DisableTrackers: true, NoDHT: true, + + NoDefaultBlocklist: true, }) defer client.Stop() log.Printf("%+v", *layout.Metainfo) @@ -121,9 +122,9 @@ func TestUnmountWedged(t *testing.T) { go func() { ioutil.ReadFile(filepath.Join(layout.MountDir, layout.Metainfo.Info.Name)) }() - time.Sleep(time.Second) + // time.Sleep(time.Second) fs.Destroy() - time.Sleep(time.Second) + // time.Sleep(time.Second) err = fuse.Unmount(layout.MountDir) if err != nil { log.Print(err) @@ -144,6 +145,8 @@ func TestDownloadOnDemand(t *testing.T) { DisableTrackers: true, NoDHT: true, ListenAddr: ":0", + + NoDefaultBlocklist: true, }) if err != nil { t.Fatalf("error creating seeder client: %s", err) @@ -164,6 +167,8 @@ func TestDownloadOnDemand(t *testing.T) { NoDHT: true, ListenAddr: ":0", + NoDefaultBlocklist: true, + // This can be used to check if clients can connect to other clients // with the same ID. diff --git a/tracker/udp/udp_tracker_test.go b/tracker/udp/udp_tracker_test.go index 56969dd6..118d2489 100644 --- a/tracker/udp/udp_tracker_test.go +++ b/tracker/udp/udp_tracker_test.go @@ -86,6 +86,9 @@ func TestConvertInt16ToInt(t *testing.T) { } func TestUDPTracker(t *testing.T) { + if testing.Short() { + t.SkipNow() + } tr, err := tracker.New("udp://tracker.openbittorrent.com:80/announce") if err != nil { t.Skip(err) @@ -107,6 +110,9 @@ func TestUDPTracker(t *testing.T) { // TODO: Create a fake UDP tracker to make these requests to. func TestAnnounceRandomInfoHash(t *testing.T) { + if testing.Short() { + t.SkipNow() + } wg := sync.WaitGroup{} for _, url := range []string{ "udp://tracker.openbittorrent.com:80/announce",