From 2315ed49d7f1249e8301a57965c5273f59bcc5db Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 5 Jun 2023 11:22:47 +0200 Subject: [PATCH 1/2] chore: resolve lint errors --- datasegment/commp_test.go | 2 ++ datasegment/creation_test.go | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/datasegment/commp_test.go b/datasegment/commp_test.go index e9bc101..bfb9467 100644 --- a/datasegment/commp_test.go +++ b/datasegment/commp_test.go @@ -16,6 +16,7 @@ func TestLightCommP2Cid(t *testing.T) { c1, err := commcid.PieceCommitmentV1ToCID(node[:]) assert.NoError(t, err) c2, err := lightCommP2Cid(node) + assert.NoError(t, err) assert.Equal(t, c1, c2) } @@ -28,6 +29,7 @@ func TestLightCid2CommP(t *testing.T) { c, err := commcid.PieceCommitmentV1ToCID(node[:]) assert.NoError(t, err) n1, err := lightCid2CommP(c) + assert.NoError(t, err) assert.Equal(t, node, n1) diff --git a/datasegment/creation_test.go b/datasegment/creation_test.go index 2832384..2ef7a71 100644 --- a/datasegment/creation_test.go +++ b/datasegment/creation_test.go @@ -55,6 +55,7 @@ func TestAggregateCreation(t *testing.T) { for _, pi := range subPieceInfos { ip, err := a.ProofForPieceInfo(pi) + assert.NoError(t, err) aux, err := ip.ComputeExpectedAuxData(VerifierDataForPieceInfo(pi)) assert.NoError(t, err) assert.Equal(t, InclusionAuxData{CommPa: pcid, SizePa: a.DealSize}, *aux) @@ -238,7 +239,8 @@ func TestAggregateSample(t *testing.T) { require.NoError(t, err) { - _, err = f.Seek(int64(a.Index.Entries[0].UnpaddedOffest()), os.SEEK_SET) + _, err = f.Seek(int64(a.Index.Entries[0].UnpaddedOffest()), io.SeekStart) + require.NoError(t, err) p0, err := os.Open("testdata/sample_aggregate/cat.png.car") require.NoError(t, err) _, err = io.Copy(f, p0) @@ -247,7 +249,7 @@ func TestAggregateSample(t *testing.T) { { p1, err := os.Open("testdata/sample_aggregate/Verifiable Data Aggregation.png.car") require.NoError(t, err) - _, err = f.Seek(int64(a.Index.Entries[1].UnpaddedOffest()), os.SEEK_SET) + _, err = f.Seek(int64(a.Index.Entries[1].UnpaddedOffest()), io.SeekStart) require.NoError(t, err) _, err = io.Copy(f, p1) require.NoError(t, err) @@ -257,7 +259,7 @@ func TestAggregateSample(t *testing.T) { { index_start, err := a.IndexStartPosition() require.NoError(t, err) - _, err = f.Seek(int64(index_start), os.SEEK_SET) + _, err = f.Seek(int64(index_start), io.SeekStart) require.NoError(t, err) r, err := a.IndexReader() require.NoError(t, err) @@ -271,7 +273,7 @@ func TestAggregateSample(t *testing.T) { { indexStart := DataSegmentIndexStartOffset(dealSize) - f.Seek(int64(indexStart), os.SEEK_SET) + f.Seek(int64(indexStart), io.SeekStart) indexData, err := ParseDataSegmentIndex(f) require.NoError(t, err) @@ -296,6 +298,7 @@ func TestAggregateSample(t *testing.T) { assert.NoError(t, err) commp, paddedSize, err := commpHasher.Digest() + assert.NoError(t, err) pieceCid := Must(commcid.PieceCommitmentV1ToCID(commp)) assert.Equal(t, uint64(dealSize), uint64(paddedSize)) assert.Equal(t, cid.MustParse("baga6ea4seaqnqkeoqevjjjfe46wo2lpfclcbmkyms4wkz5srou3vzmr3w3c72bq"), From 7c630830e9eaf0b5cea8e345e4f4a8c166917563 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 5 Jun 2023 11:31:35 +0200 Subject: [PATCH 2/2] misc: fix error message --- datasegment/index.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datasegment/index.go b/datasegment/index.go index 8a9dbbe..cdc4f36 100644 --- a/datasegment/index.go +++ b/datasegment/index.go @@ -260,10 +260,10 @@ func (sd SegmentDesc) Validate() error { return validationError("computed checksum does not match embedded checksum") } if sd.Offset%128 != 0 { - return validationError("offset is not aligned in unpadded data") + return validationError("offset is not aligned in padded data") } if sd.Size%128 != 0 { - return validationError("size is not aligned in unpadded data") + return validationError("size is not aligned in padded data") } return nil }