Skip to content

Commit 506ab97

Browse files
authored
cmd/swarm-smoke: prevent smoke test from executing trackChunks twice when we debug (ethersphere#1717)
1 parent 08cd528 commit 506ab97

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

cmd/swarm-smoke/upload_and_sync.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,10 @@ func uploadAndSyncCmd(ctx *cli.Context) error {
6767
err = fmt.Errorf("timeout after %v sec", timeout)
6868
}
6969

70-
if debug {
71-
// trigger debug functionality on randomBytes
72-
e := trackChunks(randomBytes[:], true)
73-
if e != nil {
74-
log.Error(e.Error())
75-
}
76-
}
77-
7870
return err
7971
}
8072

81-
func trackChunks(testData []byte, submitMetrics bool) error {
73+
func trackChunks(testData []byte) error {
8274
addrs, err := getAllRefs(testData)
8375
if err != nil {
8476
return err
@@ -154,20 +146,18 @@ func trackChunks(testData []byte, submitMetrics bool) error {
154146

155147
log.Debug("chunks", "chunks", hostChunks, "yes", yes, "no", no, "host", host)
156148

157-
if submitMetrics {
158-
globalMu.Lock()
159-
globalYes += yes
160-
globalNo += no
161-
globalMu.Unlock()
162-
}
149+
globalMu.Lock()
150+
globalYes += yes
151+
globalNo += no
152+
globalMu.Unlock()
163153
}()
164154
}
165155

166156
wg.Wait()
167157

168158
checkChunksVsMostProxHosts(addrs, allHostChunks, bzzAddrs)
169159

170-
if !hasErr && submitMetrics {
160+
if !hasErr {
171161
// remove the chunks stored on the uploader node
172162
globalYes -= len(addrs)
173163

@@ -301,7 +291,7 @@ func uploadAndSync(c *cli.Context, randomBytes []byte) error {
301291
log.Debug("chunks before fetch attempt", "hash", hash)
302292

303293
if debug {
304-
err = trackChunks(randomBytes, false)
294+
err = trackChunks(randomBytes)
305295
if err != nil {
306296
log.Error(err.Error())
307297
}

0 commit comments

Comments
 (0)