diff options
author | Ferenc Szabo <frncmx@gmail.com> | 2019-01-17 23:45:36 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-19 20:09:09 +0800 |
commit | 710775f43574ca7bdd039abb7474f34a4e4fe9fd (patch) | |
tree | 7eb6812722f78454ca39d58988ecfeaedbbe51e8 /swarm/network/fetcher_test.go | |
parent | 0fd0108507ee54e671a4372bab1309c6fbe1b18d (diff) | |
download | go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar.gz go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar.bz2 go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar.lz go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar.xz go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.tar.zst go-tangerine-710775f43574ca7bdd039abb7474f34a4e4fe9fd.zip |
swarm/network: fix data race in fetcher_test.go (#18469)
(cherry picked from commit 19bfcbf9117f39f54f698a0953534d90c08e9930)
Diffstat (limited to 'swarm/network/fetcher_test.go')
-rw-r--r-- | swarm/network/fetcher_test.go | 16 |
1 files changed, 5 insertions, 11 deletions
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{} |