From 197bf15bf9d9cdef096bd7fea7a857bd886e4987 Mon Sep 17 00:00:00 2001 From: ChengenH Date: Fri, 13 Dec 2024 18:18:28 +0800 Subject: [PATCH] refactor: unify the error handling methods in the crypto package that are different from the project style Signed-off-by: ChengenH --- export_test.go | 9 +++++---- import_test.go | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/export_test.go b/export_test.go index 9772e2ed1..de83a4c98 100644 --- a/export_test.go +++ b/export_test.go @@ -1,6 +1,7 @@ package iavl import ( + "errors" "math" "math/rand" "testing" @@ -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) @@ -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) @@ -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 @@ -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) diff --git a/import_test.go b/import_test.go index 9f4d49aee..fd3621c1d 100644 --- a/import_test.go +++ b/import_test.go @@ -1,6 +1,7 @@ package iavl import ( + "errors" "testing" "github.com/stretchr/testify/assert" @@ -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) @@ -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)