]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent_test.go
Fix race condition in TestPieceHashFailed
[btrtrc.git] / torrent_test.go
index 9fe3e96374ff5c3cbe25277b1567d5e92c73587b..51c26c67443f3145c740e578ff263751810cea40 100644 (file)
@@ -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()
 }