From 710775f43574ca7bdd039abb7474f34a4e4fe9fd Mon Sep 17 00:00:00 2001 From: Ferenc Szabo Date: Thu, 17 Jan 2019 16:45:36 +0100 Subject: swarm/network: fix data race in fetcher_test.go (#18469) (cherry picked from commit 19bfcbf9117f39f54f698a0953534d90c08e9930) --- swarm/network/fetcher_test.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'swarm/network/fetcher_test.go') diff --git a/swarm/network/fetcher_test.go b/swarm/network/fetcher_test.go index 3a926f475..563c6cece 100644 --- a/swarm/network/fetcher_test.go +++ b/swarm/network/fetcher_test.go @@ -284,15 +284,11 @@ func TestFetcherRetryOnTimeout(t *testing.T) { requester := newMockRequester() addr := make([]byte, 32) fetcher := NewFetcher(addr, requester.doRequest, true) + // set searchTimeOut to low value so the test is quicker + fetcher.searchTimeout = 250 * time.Millisecond peersToSkip := &sync.Map{} - // set searchTimeOut to low value so the test is quicker - defer func(t time.Duration) { - searchTimeout = t - }(searchTimeout) - searchTimeout = 250 * time.Millisecond - ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -359,11 +355,9 @@ func TestFetcherRequestQuitRetriesRequest(t *testing.T) { addr := make([]byte, 32) fetcher := NewFetcher(addr, requester.doRequest, true) - // make sure searchTimeout is long so it is sure the request is not retried because of timeout - defer func(t time.Duration) { - searchTimeout = t - }(searchTimeout) - searchTimeout = 10 * time.Second + // make sure the searchTimeout is long so it is sure the request is not + // retried because of timeout + fetcher.searchTimeout = 10 * time.Second peersToSkip := &sync.Map{} -- cgit v1.2.3