From 6c761b340929aac8fc4cd4f580539adb251af1cf Mon Sep 17 00:00:00 2001 From: Jorropo Date: Thu, 9 Feb 2023 20:02:06 +0100 Subject: [PATCH] test: fix tests after hamt issues fixes This commit was moved from ipfs/go-unixfs@6727e33d441dba5b2c97c309c1c9fa1b49e78047 --- unixfs/hamt/hamt_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/unixfs/hamt/hamt_test.go b/unixfs/hamt/hamt_test.go index c68e05632..2b9a7f404 100644 --- a/unixfs/hamt/hamt_test.go +++ b/unixfs/hamt/hamt_test.go @@ -31,7 +31,10 @@ func makeDir(ds ipld.DAGService, size int) ([]string, *Shard, error) { func makeDirWidth(ds ipld.DAGService, size, width int) ([]string, *Shard, error) { ctx := context.Background() - s, _ := NewShard(ds, width) + s, err := NewShard(ds, width) + if err != nil { + return nil, nil, err + } var dirs []string for i := 0; i < size; i++ { @@ -42,8 +45,11 @@ func makeDirWidth(ds ipld.DAGService, size, width int) ([]string, *Shard, error) for i := 0; i < len(dirs); i++ { nd := ft.EmptyDirNode() - ds.Add(ctx, nd) - err := s.Set(ctx, dirs[i], nd) + err := ds.Add(ctx, nd) + if err != nil { + return nil, nil, err + } + err = s.Set(ctx, dirs[i], nd) if err != nil { return nil, nil, err } @@ -126,7 +132,7 @@ func assertSerializationWorks(ds ipld.DAGService, s *Shard) error { func TestBasicSet(t *testing.T) { ds := mdtest.Mock() - for _, w := range []int{128, 256, 512, 1024, 2048, 4096} { + for _, w := range []int{128, 256, 512, 1024} { t.Run(fmt.Sprintf("BasicSet%d", w), func(t *testing.T) { names, s, err := makeDirWidth(ds, 1000, w) if err != nil { @@ -740,7 +746,7 @@ func TestHamtBadSize(t *testing.T) { for _, size := range [...]int{-8, 7, 2, 1337, 1024 + 8, -3} { _, err := NewShard(nil, size) if err == nil { - t.Error("should have failed to construct hamt with bad size: %d", size) + t.Errorf("should have failed to construct hamt with bad size: %d", size) } } }