From 013fa1df5a5d4bcf3aa66f490d06ffb1c80fb036 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 17 Apr 2020 11:40:03 +1000 Subject: [PATCH] Fix transfer test check for seeder piece counts 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/transfer_test.go b/test/transfer_test.go index 30402793..d3ec5ff8 100644 --- a/test/transfer_test.go +++ b/test/transfer_test.go @@ -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() -- 2.48.1