Skip to content

Commit

Permalink
refactor: unify the error handling methods in the crypto package that…
Browse files Browse the repository at this point in the history
… are different from the project style (#1016)

Signed-off-by: ChengenH <[email protected]>
  • Loading branch information
ChengenH authored Dec 13, 2024
1 parent 73b21dd commit d89d5d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion benchmarks/cosmos-exim/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
"os"
"time"
Expand Down Expand Up @@ -128,7 +129,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) {
defer exporter.Close()
for {
node, err := exporter.Next()
if err == iavl.ErrorExportDone {
if errors.Is(err, iavl.ErrorExportDone) {
break
} else if err != nil {
return 0, nil, err
Expand Down
9 changes: 5 additions & 4 deletions export_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package iavl

import (
"errors"
"math"
"math/rand"
"testing"
Expand Down Expand Up @@ -180,7 +181,7 @@ func TestExporter(t *testing.T) {
defer exporter.Close()
for {
node, err := exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
break
}
require.NoError(t, err)
Expand Down Expand Up @@ -215,7 +216,7 @@ func TestExporterCompress(t *testing.T) {
exporter := NewCompressExporter(innerExporter)
for {
node, err := exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
break
}
require.NoError(t, err)
Expand Down Expand Up @@ -266,7 +267,7 @@ func TestExporter_Import(t *testing.T) {

for {
item, err := exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
err = innerImporter.Commit()
require.NoError(t, err)
break
Expand Down Expand Up @@ -365,7 +366,7 @@ func BenchmarkExport(b *testing.B) {
require.NoError(b, err)
for {
_, err := exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
break
} else if err != nil {
b.Error(err)
Expand Down
5 changes: 3 additions & 2 deletions import_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package iavl

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -43,7 +44,7 @@ func ExampleImporter() {
for {
var node *ExportNode
node, err = exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
break
} else if err != nil {
panic(err)
Expand Down Expand Up @@ -247,7 +248,7 @@ func benchmarkImport(b *testing.B, nodes int) {
require.NoError(b, err)
for {
item, err := exporter.Next()
if err == ErrorExportDone {
if errors.Is(err, ErrorExportDone) {
break
} else if err != nil {
b.Error(err)
Expand Down

0 comments on commit d89d5d2

Please sign in to comment.