Skip to content

Commit

Permalink
Add test for GetEntryBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Dec 9, 2024
1 parent 4eb23e9 commit 3bf41f7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,44 @@ func TestHandleZeroRoot(t *testing.T) {
t.Fatalf("NewProofBuilder: %v", err)
}
}

func TestGetEntryBundleAddressing(t *testing.T) {
for _, test := range []struct {
name string
idx, logSize uint64
wantPartialTileSize uint8
}{
{
name: "works - partial tile",
idx: 0,
logSize: 34,
wantPartialTileSize: 34,
},
{
name: "works - full tile",
idx: 1,
logSize: 256*2 + 45,
wantPartialTileSize: 0,
},
} {
t.Run(test.name, func(t *testing.T) {
gotIdx := uint64(0)
gotTileSize := uint8(0)
f := func(_ context.Context, i uint64, sz uint8) ([]byte, error) {
gotIdx = i
gotTileSize = sz
return []byte{}, nil
}
_, err := GetEntryBundle(context.Background(), f, test.idx, test.logSize)
if err != nil {
t.Fatalf("GetEntryBundle: %v", err)
}
if gotIdx != test.idx {
t.Errorf("f got idx %d, want %d", gotIdx, test.idx)
}
if gotTileSize != test.wantPartialTileSize {
t.Errorf("f got tileSize %d, want %d", gotTileSize, test.wantPartialTileSize)
}
})
}
}

0 comments on commit 3bf41f7

Please sign in to comment.