]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add test case for #464
authorMatt Joiner <anacrolix@gmail.com>
Thu, 18 Feb 2021 03:34:42 +0000 (14:34 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 18 Feb 2021 03:34:42 +0000 (14:34 +1100)
internal/cmd/issue-464/main.go [new file with mode: 0644]
testdata/The WIRED CD - Rip. Sample. Mash. Share.torrent [new file with mode: 0644]

diff --git a/internal/cmd/issue-464/main.go b/internal/cmd/issue-464/main.go
new file mode 100644 (file)
index 0000000..fbac1b4
--- /dev/null
@@ -0,0 +1,48 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "log"
+
+       "github.com/anacrolix/torrent"
+)
+
+const testMagnet = "magnet:?xt=urn:btih:a88fda5954e89178c372716a6a78b8180ed4dad3&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F"
+
+func main() {
+       err := mainErr()
+       if err != nil {
+               log.Fatalf("error in main: %v", err)
+       }
+}
+
+func mainErr() error {
+       cfg := torrent.NewDefaultClientConfig()
+       // We could disable non-webseed peer types here, to force any errors.
+       client, _ := torrent.NewClient(cfg)
+
+       // Add directly from metainfo, because we want to force webseeding to serve data, and webseeding
+       // won't get us the metainfo.
+       t, err := client.AddTorrentFromFile("testdata/The WIRED CD - Rip. Sample. Mash. Share.torrent")
+       if err != nil {
+               return err
+       }
+       <-t.GotInfo()
+
+       fmt.Println("GOT INFO")
+
+       f := t.Files()[0]
+
+       r := f.NewReader()
+
+       r.Seek(5, io.SeekStart)
+       buf := make([]byte, 5)
+       n, err := r.Read(buf)
+
+       fmt.Println("END", n, buf, err)
+
+       t.DownloadAll()
+       client.WaitAll()
+       return nil
+}
diff --git a/testdata/The WIRED CD - Rip. Sample. Mash. Share.torrent b/testdata/The WIRED CD - Rip. Sample. Mash. Share.torrent
new file mode 100644 (file)
index 0000000..e5acba5
Binary files /dev/null and b/testdata/The WIRED CD - Rip. Sample. Mash. Share.torrent differ