Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
test: fix tests after hamt issues fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Feb 9, 2023
1 parent 1e875f4 commit f00af73
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions hamt/hamt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}

0 comments on commit f00af73

Please sign in to comment.