aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanoš Guljaš <janos@users.noreply.github.com>2019-01-16 21:31:32 +0800
committerRafael Matias <rafael@skyle.net>2019-02-19 19:54:10 +0800
commitdd3e89474777b39b7bea646796de594449ea2304 (patch)
treef4a660d4b969bb542f3807171c561e5d79967f9d
parentdf355eceb41f4beec611faea0df617ea59980bef (diff)
downloaddexon-dd3e89474777b39b7bea646796de594449ea2304.tar.gz
dexon-dd3e89474777b39b7bea646796de594449ea2304.tar.zst
dexon-dd3e89474777b39b7bea646796de594449ea2304.zip
swarm/storage: fix mockNetFetcher data races (#18462)
fixes: ethersphere/go-ethereum#1117 (cherry picked from commit f728837ee6b48a2413437f54057b4552b7e77494)
-rw-r--r--swarm/storage/netstore_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/swarm/storage/netstore_test.go b/swarm/storage/netstore_test.go
index 2ed3e0752..a6a9f551a 100644
--- a/swarm/storage/netstore_test.go
+++ b/swarm/storage/netstore_test.go
@@ -43,6 +43,7 @@ type mockNetFetcher struct {
quit <-chan struct{}
ctx context.Context
hopCounts []uint8
+ mu sync.Mutex
}
func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) {
@@ -51,6 +52,9 @@ func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) {
}
func (m *mockNetFetcher) Request(ctx context.Context, hopCount uint8) {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+
m.requestCalled = true
var peers []Address
m.peers.Range(func(key interface{}, _ interface{}) bool {