aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2018-09-29 02:01:43 +0800
committerGitHub <noreply@github.com>2018-09-29 02:01:43 +0800
commit7910dd5179fc70a8bd577f70d573051afcc23aec (patch)
treef665cc9e9c7faae4563d8e85d3f5d9efc3a3bf89
parentdcaabfe7f6f38577c11a475b81ab9584ef61a4a5 (diff)
parent0ee44e796a549c7864b0c78a9cec81ac27cb30eb (diff)
downloadgo-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar.gz
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar.bz2
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar.lz
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar.xz
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.tar.zst
go-tangerine-7910dd5179fc70a8bd577f70d573051afcc23aec.zip
Merge pull request #17781 from ethersphere/trim_newline
cmd/swarm: trim new lines from files
-rw-r--r--cmd/swarm/access.go4
-rw-r--r--swarm/storage/mru/lookup/epoch_test.go6
-rw-r--r--swarm/storage/mru/lookup/lookup_test.go4
-rw-r--r--swarm/storage/mru/query.go2
4 files changed, 7 insertions, 9 deletions
diff --git a/cmd/swarm/access.go b/cmd/swarm/access.go
index 67e852dde..dd2d513c2 100644
--- a/cmd/swarm/access.go
+++ b/cmd/swarm/access.go
@@ -130,7 +130,7 @@ func accessNewACT(ctx *cli.Context) {
if err != nil {
utils.Fatalf("had an error reading the grantee public key list")
}
- pkGrantees = strings.Split(string(bytes), "\n")
+ pkGrantees = strings.Split(strings.Trim(string(bytes), "\n"), "\n")
}
if passGranteesFilename != "" {
@@ -138,7 +138,7 @@ func accessNewACT(ctx *cli.Context) {
if err != nil {
utils.Fatalf("could not read password filename: %v", err)
}
- passGrantees = strings.Split(string(bytes), "\n")
+ passGrantees = strings.Split(strings.Trim(string(bytes), "\n"), "\n")
}
accessKey, ae, actManifest, err = api.DoACT(ctx, privateKey, salt, pkGrantees, passGrantees)
if err != nil {
diff --git a/swarm/storage/mru/lookup/epoch_test.go b/swarm/storage/mru/lookup/epoch_test.go
index 8c63ec6c2..62cf5523d 100644
--- a/swarm/storage/mru/lookup/epoch_test.go
+++ b/swarm/storage/mru/lookup/epoch_test.go
@@ -42,15 +42,15 @@ func TestAfter(t *testing.T) {
Level: 4,
}
- if b.After(a) != true {
+ if !b.After(a) {
t.Fatal("Expected 'after' to be true, got false")
}
- if b.After(b) != false {
+ if b.After(b) {
t.Fatal("Expected 'after' to be false when both epochs are identical, got true")
}
- if b.After(c) != true {
+ if !b.After(c) {
t.Fatal("Expected 'after' to be true when both epochs have the same time but the level is lower in the first one, but got false")
}
diff --git a/swarm/storage/mru/lookup/lookup_test.go b/swarm/storage/mru/lookup/lookup_test.go
index ca0bb73bb..34bcb61f0 100644
--- a/swarm/storage/mru/lookup/lookup_test.go
+++ b/swarm/storage/mru/lookup/lookup_test.go
@@ -38,9 +38,7 @@ func write(store Store, epoch lookup.Epoch, value *Data) {
}
func update(store Store, last lookup.Epoch, now uint64, value *Data) lookup.Epoch {
- var epoch lookup.Epoch
-
- epoch = lookup.GetNextEpoch(last, now)
+ epoch := lookup.GetNextEpoch(last, now)
write(store, epoch, value)
diff --git a/swarm/storage/mru/query.go b/swarm/storage/mru/query.go
index 9a0f261c4..13a28eaab 100644
--- a/swarm/storage/mru/query.go
+++ b/swarm/storage/mru/query.go
@@ -36,7 +36,7 @@ type Query struct {
// useful to parse query strings
func (q *Query) FromValues(values Values) error {
time, _ := strconv.ParseUint(values.Get("time"), 10, 64)
- q.TimeLimit = uint64(time)
+ q.TimeLimit = time
level, _ := strconv.ParseUint(values.Get("hint.level"), 10, 32)
q.Hint.Level = uint8(level)