]> Sergey Matveev's repositories - btrtrc.git/commitdiff
fs: Fix tests now that data verification isn't automatic
authorMatt Joiner <anacrolix@gmail.com>
Fri, 15 Sep 2017 09:34:42 +0000 (19:34 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 15 Sep 2017 09:34:42 +0000 (19:34 +1000)
fs/torrentfs_test.go

index 2625cc3c71316fdb3c9cd33362184ac09dca7286..ab3ab4bc61e66b3a8db909935b6e09789092601b 100644 (file)
@@ -178,8 +178,15 @@ func TestDownloadOnDemand(t *testing.T) {
        require.NoError(t, err)
        defer seeder.Close()
        testutil.ExportStatusWriter(seeder, "s")
-       _, err = seeder.AddMagnet(fmt.Sprintf("magnet:?xt=urn:btih:%s", layout.Metainfo.HashInfoBytes().HexString()))
+       // Just to mix things up, the seeder starts with the data, but the leecher
+       // starts with the metainfo.
+       seederTorrent, err := seeder.AddMagnet(fmt.Sprintf("magnet:?xt=urn:btih:%s", layout.Metainfo.HashInfoBytes().HexString()))
        require.NoError(t, err)
+       go func() {
+               // Wait until we get the metainfo, then check for the data.
+               <-seederTorrent.GotInfo()
+               seederTorrent.VerifyData()
+       }()
        leecher, err := torrent.NewClient(&torrent.Config{
                DisableTrackers: true,
                NoDHT:           true,