Skip to content

Commit

Permalink
fix test and handle file close error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Feb 5, 2024
1 parent 7dba93a commit 5099a54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestBatchEquivalence(t *testing.T) {
}
}

assert.Error(t, group.BatchVerifyCommitEquivalence(commitPairs), "batch equivalence negative test failed\n")
assert.NoError(t, group.BatchVerifyCommitEquivalence(commitPairs), "batch equivalence negative test failed\n")

var modifiedCommit bn254.G1Point
bn254.AddG1(&modifiedCommit, commit, commit)
Expand All @@ -43,7 +43,7 @@ func TestBatchEquivalence(t *testing.T) {
}
}

assert.False(t, group.BatchVerifyCommitEquivalence(commitPairs) == nil, "batch equivalence negative test failed\n")
assert.Error(t, group.BatchVerifyCommitEquivalence(commitPairs), "batch equivalence negative test failed\n")

for z := 0; z < numBlob; z++ {
commitPairs[z] = kzgRs.CommitmentPair{
Expand All @@ -54,5 +54,5 @@ func TestBatchEquivalence(t *testing.T) {

bn254.AddG1(&commitPairs[numBlob/2].Commitment, &commitPairs[numBlob/2].Commitment, &commitPairs[numBlob/2].Commitment)

assert.Error(t, group.BatchVerifyCommitEquivalence(commitPairs), "batch equivalence negative test failed in outer loo\n")
assert.Error(t, group.BatchVerifyCommitEquivalence(commitPairs), "batch equivalence negative test failed in outer loop\n")
}
10 changes: 4 additions & 6 deletions pkg/encoding/utils/pointsIO.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func ReadG1Points(filepath string, n uint64, numWorker uint64) ([]bls.G1Point, e
return nil, err
}

//todo: resolve panic
defer func() {
if err := g1f.Close(); err != nil {
panic(err)
log.Printf("G1 close error %v\n", err)
}
}()

Expand Down Expand Up @@ -117,7 +116,7 @@ func ReadG1PointSection(filepath string, from, to uint64, numWorker uint64) ([]b
//todo: how to handle?
defer func() {
if err := g1f.Close(); err != nil {
panic(err)
log.Printf("g1 close error %v\n", err)
}
}()

Expand Down Expand Up @@ -229,7 +228,7 @@ func ReadG2Points(filepath string, n uint64, numWorker uint64) ([]bls.G2Point, e
//todo: resolve panic
defer func() {
if err := g1f.Close(); err != nil {
panic(err)
log.Printf("g2 close error", err)
}
}()

Expand Down Expand Up @@ -296,10 +295,9 @@ func ReadG2PointSection(filepath string, from, to uint64, numWorker uint64) ([]b
return nil, err
}

//todo: how to handle?
defer func() {
if err := g2f.Close(); err != nil {
panic(err)
log.Printf("error %v\n", err)
}
}()

Expand Down

0 comments on commit 5099a54

Please sign in to comment.