Commit 1aabde8d authored by Steven Allen's avatar Steven Allen

chore: fix a bunch of issues caught by golangci-lint

Most of these are probably harmless but a few looked like they might actually be
bugs. Most of them are just faulty tests.

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent eb33dc1f
...@@ -2,6 +2,7 @@ package pin ...@@ -2,6 +2,7 @@ package pin
import ( import (
"context" "context"
"io"
"testing" "testing"
"time" "time"
...@@ -21,7 +22,10 @@ var rand = util.NewTimeSeededRand() ...@@ -21,7 +22,10 @@ var rand = util.NewTimeSeededRand()
func randNode() (*mdag.ProtoNode, cid.Cid) { func randNode() (*mdag.ProtoNode, cid.Cid) {
nd := new(mdag.ProtoNode) nd := new(mdag.ProtoNode)
nd.SetData(make([]byte, 32)) nd.SetData(make([]byte, 32))
rand.Read(nd.Data()) _, err := io.ReadFull(rand, nd.Data())
if err != nil {
panic(err)
}
k := nd.Cid() k := nd.Cid()
return nd, k return nd, k
} }
...@@ -111,11 +115,11 @@ func TestPinnerBasic(t *testing.T) { ...@@ -111,11 +115,11 @@ func TestPinnerBasic(t *testing.T) {
assertPinned(t, p, bk, "Recursively pinned node not found..") assertPinned(t, p, bk, "Recursively pinned node not found..")
d, _ := randNode() d, _ := randNode()
d.AddNodeLink("a", a) _ = d.AddNodeLink("a", a)
d.AddNodeLink("c", c) _ = d.AddNodeLink("c", c)
e, _ := randNode() e, _ := randNode()
d.AddNodeLink("e", e) _ = d.AddNodeLink("e", e)
// Must be in dagserv for unpin to work // Must be in dagserv for unpin to work
err = dserv.Add(ctx, e) err = dserv.Add(ctx, e)
...@@ -385,8 +389,12 @@ func TestPinUpdate(t *testing.T) { ...@@ -385,8 +389,12 @@ func TestPinUpdate(t *testing.T) {
n1, c1 := randNode() n1, c1 := randNode()
n2, c2 := randNode() n2, c2 := randNode()
dserv.Add(ctx, n1) if err := dserv.Add(ctx, n1); err != nil {
dserv.Add(ctx, n2) t.Fatal(err)
}
if err := dserv.Add(ctx, n2); err != nil {
t.Fatal(err)
}
if err := p.Pin(ctx, n1, true); err != nil { if err := p.Pin(ctx, n1, true); err != nil {
t.Fatal(err) t.Fatal(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment