]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix transfer test check for seeder piece counts
authorMatt Joiner <anacrolix@gmail.com>
Fri, 17 Apr 2020 01:40:03 +0000 (11:40 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 17 Apr 2020 01:40:25 +0000 (11:40 +1000)
I suspect that there's a race where a connection is established to the seeder, but we haven't received it's completed piece information yet, and we already finished reading all the data we need from another connection. Probably comes up now because pending peers with the same address aren't clobbering each other since that was fixed.

test/transfer_test.go

index 30402793d963c3a26949b52594caed4e2166927a..d3ec5ff8625ba1215ff2082d1e0353acf494fb30 100644 (file)
@@ -134,8 +134,16 @@ func testClientTransfer(t *testing.T, ps testClientTransferParams) {
        assert.NotEmpty(t, seederTorrent.PeerConns())
        leecherPeerConns := leecherTorrent.PeerConns()
        assert.NotEmpty(t, leecherPeerConns)
+       foundSeeder := false
        for _, pc := range leecherPeerConns {
-               assert.EqualValues(t, leecherTorrent.Info().NumPieces(), pc.PeerPieces().Len())
+               completed := pc.PeerPieces().Len()
+               t.Logf("peer conn %v has %v completed pieces", pc, completed)
+               if completed == leecherTorrent.Info().NumPieces() {
+                       foundSeeder = true
+               }
+       }
+       if !foundSeeder {
+               t.Errorf("didn't find seeder amongst leecher peer conns")
        }
 
        seederStats := seederTorrent.Stats()