From 5099a54a7c6af89f327ac14613fa1ae0e03ee7c3 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 5 Feb 2024 19:26:44 +0000 Subject: [PATCH] fix test and handle file close error --- pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go | 6 +++--- pkg/encoding/utils/pointsIO.go | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go b/pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go index bbfebaa63f..3f8834f649 100644 --- a/pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go +++ b/pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go @@ -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) @@ -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{ @@ -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") } diff --git a/pkg/encoding/utils/pointsIO.go b/pkg/encoding/utils/pointsIO.go index fc90cb2f3e..a7b0cedda5 100644 --- a/pkg/encoding/utils/pointsIO.go +++ b/pkg/encoding/utils/pointsIO.go @@ -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) } }() @@ -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) } }() @@ -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) } }() @@ -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) } }()