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

test: fix tests after hamt issues fixes #138

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}