Skip to content

Commit cf3b187

Browse files
nonsensezelig
authored andcommitted
swarm, cmd/swarm: address ineffectual assignments (#18048)
* swarm, cmd/swarm: address ineffectual assignments * swarm/network: remove unused vars from testHandshake * swarm/storage/feed: revert cursor changes
1 parent 81533de commit cf3b187

20 files changed

Lines changed: 61 additions & 24 deletions

‎cmd/swarm/access.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func accessNewPass(ctx *cli.Context) {
114114
utils.Fatalf("error getting session key: %v", err)
115115
}
116116
m, err := api.GenerateAccessControlManifest(ctx, ref, accessKey, ae)
117+
if err != nil {
118+
utils.Fatalf("had an error generating the manifest: %v", err)
119+
}
117120
if dryRun {
118121
err = printManifests(m, nil)
119122
if err != nil {
@@ -147,6 +150,9 @@ func accessNewPK(ctx *cli.Context) {
147150
utils.Fatalf("error getting session key: %v", err)
148151
}
149152
m, err := api.GenerateAccessControlManifest(ctx, ref, sessionKey, ae)
153+
if err != nil {
154+
utils.Fatalf("had an error generating the manifest: %v", err)
155+
}
150156
if dryRun {
151157
err = printManifests(m, nil)
152158
if err != nil {

‎cmd/swarm/fs_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ func TestCLISwarmFs(t *testing.T) {
8080
t.Fatal(err)
8181
}
8282
dirPath2, err := createDirInDir(dirPath, "AnotherTestSubDir")
83+
if err != nil {
84+
t.Fatal(err)
85+
}
8386

8487
dummyContent := "somerandomtestcontentthatshouldbeasserted"
8588
dirs := []string{

‎cmd/swarm/upload_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ func testCLISwarmUpRecursive(toEncrypt bool, t *testing.T) {
243243
}
244244
defer os.RemoveAll(tmpDownload)
245245
bzzLocator := "bzz:/" + hash
246-
flagss := []string{}
247-
flagss = []string{
246+
flagss := []string{
248247
"--bzzapi", cluster.Nodes[0].URL,
249248
"down",
250249
"--recursive",

‎swarm/api/act.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ func DoACT(ctx *cli.Context, privateKey *ecdsa.PrivateKey, salt []byte, grantees
458458
return nil, nil, nil, err
459459
}
460460
sessionKey, err := NewSessionKeyPK(privateKey, granteePub, salt)
461+
if err != nil {
462+
return nil, nil, nil, err
463+
}
461464

462465
hasher := sha3.NewKeccak256()
463466
hasher.Write(append(sessionKey, 0))

‎swarm/api/client/client_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ func TestClientCreateUpdateFeed(t *testing.T) {
457457
}
458458

459459
feedManifestHash, err := client.CreateFeedWithManifest(createRequest)
460+
if err != nil {
461+
t.Fatal(err)
462+
}
460463

461464
correctManifestAddrHex := "0e9b645ebc3da167b1d56399adc3276f7a08229301b72a03336be0e7d4b71882"
462465
if feedManifestHash != correctManifestAddrHex {

‎swarm/api/filesystem.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ func (fs *FileSystem) Upload(lpath, index string, toEncrypt bool) (string, error
122122
var wait func(context.Context) error
123123
ctx := context.TODO()
124124
hash, wait, err = fs.api.fileStore.Store(ctx, f, stat.Size(), toEncrypt)
125+
if err != nil {
126+
errors[i] = err
127+
return
128+
}
125129
if hash != nil {
126130
list[i].Hash = hash.Hex()
127131
}

‎swarm/api/http/server.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func (s *Server) handleMultipartUpload(r *http.Request, boundary string, mw *api
366366
}
367367

368368
var size int64
369-
var reader io.Reader = part
369+
var reader io.Reader
370370
if contentLength := part.Header.Get("Content-Length"); contentLength != "" {
371371
size, err = strconv.ParseInt(contentLength, 10, 64)
372372
if err != nil {

‎swarm/api/http/server_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func TestBzzFeed(t *testing.T) {
263263
if resp.StatusCode == http.StatusOK {
264264
t.Fatal("Expected error status since feed update does not contain multihash. Received 200 OK")
265265
}
266-
b, err = ioutil.ReadAll(resp.Body)
266+
_, err = ioutil.ReadAll(resp.Body)
267267
if err != nil {
268268
t.Fatal(err)
269269
}
@@ -491,6 +491,9 @@ func testBzzGetPath(encrypted bool, t *testing.T) {
491491
}
492492
defer resp.Body.Close()
493493
respbody, err = ioutil.ReadAll(resp.Body)
494+
if err != nil {
495+
t.Fatalf("Error while reading response body: %v", err)
496+
}
494497

495498
if string(respbody) != testmanifest[v] {
496499
isexpectedfailrequest := false

‎swarm/api/manifest.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ func (mt *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *manif
557557
if path != entry.Path {
558558
return nil, 0
559559
}
560-
pos = epl
561560
}
562561
}
563562
return nil, 0

‎swarm/network/hive_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func TestHiveStatePersistance(t *testing.T) {
7070
defer os.RemoveAll(dir)
7171

7272
store, err := state.NewDBStore(dir) //start the hive with an empty dbstore
73+
if err != nil {
74+
t.Fatal(err)
75+
}
7376

7477
params := NewHiveParams()
7578
s, pp := newHiveTester(t, params, 5, store)
@@ -90,6 +93,9 @@ func TestHiveStatePersistance(t *testing.T) {
9093
store.Close()
9194

9295
persistedStore, err := state.NewDBStore(dir) //start the hive with an empty dbstore
96+
if err != nil {
97+
t.Fatal(err)
98+
}
9399

94100
s1, pp := newHiveTester(t, params, 1, persistedStore)
95101

0 commit comments

Comments
 (0)