From bb4d3442353549ca4cc248dc581651c2ad00c94e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 13 Dec 2016 14:44:00 +1100 Subject: [PATCH] Fix race condition in TestPieceHashFailed --- torrent_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torrent_test.go b/torrent_test.go index 9fe3e963..51c26c67 100644 --- a/torrent_test.go +++ b/torrent_test.go @@ -142,9 +142,11 @@ func TestPieceHashFailed(t *testing.T) { chunkSize: 2, } require.NoError(t, tt.setInfoBytes(mi.InfoBytes)) + tt.cl.mu.Lock() tt.pieces[1].DirtyChunks.AddRange(0, 3) require.True(t, tt.pieceAllDirty(1)) tt.pieceHashed(1, false) // Dirty chunks should be cleared so we can try again. require.False(t, tt.pieceAllDirty(1)) + tt.cl.mu.Unlock() } -- 2.48.1