]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Avoid race condition in test
authorMatt Joiner <anacrolix@gmail.com>
Thu, 12 Oct 2017 05:06:14 +0000 (16:06 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 12 Oct 2017 05:06:14 +0000 (16:06 +1100)
client_test.go

index d420a78f4cb0f769a4473385b0bbb61b154b9e4e..fc008b99e399a9a334571ff8db6afa8af35cb078 100644 (file)
@@ -112,7 +112,9 @@ func TestTorrentInitialState(t *testing.T) {
        tor.storageOpener = storage.NewClient(storage.NewFileWithCompletion("/dev/null", storage.NewMapPieceCompletion()))
        // Needed to lock for asynchronous piece verification.
        tor.cl = new(Client)
+       tor.cl.mu.Lock()
        err := tor.setInfoBytes(mi.InfoBytes)
+       tor.cl.mu.Unlock()
        require.NoError(t, err)
        require.Len(t, tor.pieces, 3)
        tor.pendAllChunkSpecs(0)