Avoid race condition in test

This commit is contained in:
Matt Joiner 2017-10-12 16:06:14 +11:00
parent 17ea4f7fdd
commit 083d2120f3
1 changed files with 2 additions and 0 deletions

View 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)