]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Speed up tests, allow -short for some UDP tracker stuff
authorMatt Joiner <anacrolix@gmail.com>
Tue, 2 Dec 2014 20:23:01 +0000 (14:23 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 2 Dec 2014 20:23:01 +0000 (14:23 -0600)
client.go
client_test.go
config.go
fs/torrentfs_test.go
tracker/udp/udp_tracker_test.go

index 24af34da4f8c636e92ac1a654fae409e525c9dc4..5625f017ee96cbc3cc74a2fb87a640265ce112c5 100644 (file)
--- 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 {
index 207790df72b39f372408fadbd26bfa96e0185889..e5ee79d268f70174b5ba20c24830338295ea3ef5 100644 (file)
@@ -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)
        }
index 9b1cae618f069d8c0615e44d625d8416020d27c2..c78db5be6f84d246dd6f1e31ee863f82f67c1e4a 100644 (file)
--- 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
 }
index 372b8f2992fea3f3e509b1b6fb0a9b0a4cfe8d72..2f9c79fb87d0ddd6481403ae340f55b41ddd8bb6 100644 (file)
@@ -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.
 
index 56969dd647492f2a566cae051436866436784d26..118d2489a8473516bb830a6c8f5882bf246ccd84 100644 (file)
@@ -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",