Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Oct 11, 2023
1 parent 1f4e0d1 commit 5a0c20f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (b *Blob) UnmarshalJSON(data []byte) error {
// It will build blobs either until appShares will be empty or the first incomplete blob will appear, so in this
// specific case it will return all built blobs + remaining shares.
func buildBlobsIfExist(appShares []shares.Share) ([]*Blob, []shares.Share, error) {
blobs := make([]*Blob, 0)
blobs := make([]*Blob, 0, len(appShares))
for {
if len(appShares) == 0 {
return blobs, nil, nil
Expand Down
19 changes: 19 additions & 0 deletions blob/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,25 @@ func TestService_GetSingleBlobWithoutPadding(t *testing.T) {
assert.Equal(t, newBlob.Commitment, blobs[1].Commitment)
}

func TestService_Get(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
t.Cleanup(cancel)

sizes := []int{1, 6, 3, 2, 4, 6, 8, 2, 15, 17}

appBlobs, err := blobtest.GenerateV0Blobs(sizes, true)
require.NoError(t, err)
blobs, err := convertBlobs(appBlobs...)
require.NoError(t, err)

service := createService(ctx, t, blobs)
for _, blob := range blobs {
b, err := service.Get(ctx, 1, blob.Namespace(), blob.Commitment)
require.NoError(t, err)
assert.Equal(t, b.Commitment, blob.Commitment)
}
}

func TestService_GetAllWithoutPadding(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
t.Cleanup(cancel)
Expand Down

0 comments on commit 5a0c20f

Please sign in to comment.