From 0b80043abbe14aed3b5e6c519d6f75deda8abe3c Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Thu, 21 Feb 2019 13:32:21 +0100 Subject: [PATCH] swarm/storage/localstore: stop sending to errChan on context done in tests --- swarm/storage/localstore/subscription_pull_test.go | 6 +++++- swarm/storage/localstore/subscription_push_test.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/swarm/storage/localstore/subscription_pull_test.go b/swarm/storage/localstore/subscription_pull_test.go index 03a19a2f7d..c8649bb834 100644 --- a/swarm/storage/localstore/subscription_pull_test.go +++ b/swarm/storage/localstore/subscription_pull_test.go @@ -453,7 +453,11 @@ func readPullSubscriptionBin(ctx context.Context, bin uint8, ch <-chan ChunkDesc } i++ // send one and only one error per received address - errChan <- err + select { + case errChan <- err: + case <-ctx.Done(): + return + } case <-ctx.Done(): return } diff --git a/swarm/storage/localstore/subscription_push_test.go b/swarm/storage/localstore/subscription_push_test.go index 73e7c25f72..f1a0df7a34 100644 --- a/swarm/storage/localstore/subscription_push_test.go +++ b/swarm/storage/localstore/subscription_push_test.go @@ -90,7 +90,11 @@ func TestDB_SubscribePush(t *testing.T) { } i++ // send one and only one error per received address - errChan <- err + select { + case errChan <- err: + case <-ctx.Done(): + return + } case <-ctx.Done(): return } @@ -175,7 +179,11 @@ func TestDB_SubscribePush_multiple(t *testing.T) { } i++ // send one and only one error per received address - errChan <- err + select { + case errChan <- err: + case <-ctx.Done(): + return + } case <-ctx.Done(): return }