From 09c184aa0ee4fe9e3d265eba2e76033d0aad2022 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Thu, 21 Feb 2019 12:21:36 +0100 Subject: [PATCH] swarm/storage/localstore: fix a possible deadlock in tests --- swarm/storage/localstore/subscription_pull_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swarm/storage/localstore/subscription_pull_test.go b/swarm/storage/localstore/subscription_pull_test.go index 16fe8b0ddc..415485cd12 100644 --- a/swarm/storage/localstore/subscription_pull_test.go +++ b/swarm/storage/localstore/subscription_pull_test.go @@ -473,14 +473,14 @@ func readPullSubscriptionBin(ctx context.Context, bin uint8, ch <-chan ChunkDesc if !ok { return } + var err error addrsMu.Lock() if i+1 > len(addrs[bin]) { - errChan <- fmt.Errorf("got more chunk addresses %v, then expected %v, for bin %v", i+1, len(addrs[bin]), bin) + err = fmt.Errorf("got more chunk addresses %v, then expected %v, for bin %v", i+1, len(addrs[bin]), bin) } want := addrs[bin][i] addrsMu.Unlock() - var err error - if !bytes.Equal(got.Address, want) { + if err == nil && !bytes.Equal(got.Address, want) { err = fmt.Errorf("got chunk address %v in bin %v %s, want %s", i, bin, got.Address.Hex(), want) } i++