Skip to content

Commit

Permalink
chore: use ignite errors pkg (#4148)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored May 16, 2024
1 parent 3dca0a8 commit fd5d841
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
12 changes: 6 additions & 6 deletions ignite/internal/plugin/testdata/execute_fail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@ package main

import (
"context"
"errors"

hplugin "github.com/hashicorp/go-plugin"

"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/plugin"
)

type app struct{}

func (app) Manifest(ctx context.Context) (*plugin.Manifest, error) {
func (app) Manifest(context.Context) (*plugin.Manifest, error) {
return &plugin.Manifest{
Name: "execute_fail",
}, nil
}

func (app) Execute(ctx context.Context, cmd *plugin.ExecutedCommand, api plugin.ClientAPI) error {
func (app) Execute(context.Context, *plugin.ExecutedCommand, plugin.ClientAPI) error {
return errors.New("fail")
}

func (app) ExecuteHookPre(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookPre(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

func (app) ExecuteHookPost(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookPost(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

func (app) ExecuteHookCleanUp(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookCleanUp(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cosmoserror/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestUnwrap(t *testing.T) {
},
{
name: "should return not found with wrapped error",
err: fmt.Errorf("oups: %w", status.Error(codes.NotFound, "test error 4")),
err: errors.Errorf("oups: %w", status.Error(codes.NotFound, "test error 4")),
want: cosmoserror.ErrNotFound,
},
{
Expand All @@ -45,7 +45,7 @@ func TestUnwrap(t *testing.T) {
},
{
name: "should unwrap error",
err: fmt.Errorf("test error 4: %w", errors.New("test error 6")),
err: fmt.Errorf("test error 4: %w", errors.New("test error 6")), //nolint:forbidigo
want: errors.New("test error 6"),
},
}
Expand Down
15 changes: 8 additions & 7 deletions integration/relayer/cmd_relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/availableport"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/goanalysis"
"github.com/ignite/cli/v29/ignite/pkg/xyaml"
envtest "github.com/ignite/cli/v29/integration"
Expand Down Expand Up @@ -491,14 +492,14 @@ func TestBlogIBC(t *testing.T) {
return execErr
}
if err := json.Unmarshal(queryOutput.Bytes(), &queryResponse); err != nil {
return fmt.Errorf("unmarshling tx response: %w", err)
return errors.Errorf("unmarshling tx response: %w", err)
}
if len(queryResponse.Channels) == 0 ||
len(queryResponse.Channels[0].ConnectionHops) == 0 {
return fmt.Errorf("channel not found")
return errors.Errorf("channel not found")
}
if queryResponse.Channels[0].State != "STATE_OPEN" {
return fmt.Errorf("channel is not open")
return errors.Errorf("channel is not open")
}
return nil
}),
Expand Down Expand Up @@ -542,7 +543,7 @@ func TestBlogIBC(t *testing.T) {
return execErr
}
if err := json.Unmarshal(txOutput.Bytes(), &txResponse); err != nil {
return fmt.Errorf("unmarshling tx response: %w", err)
return errors.Errorf("unmarshling tx response: %w", err)
}
return cmdrunner.New().Run(ctx, step.New(
step.Exec(
Expand Down Expand Up @@ -607,13 +608,13 @@ func TestBlogIBC(t *testing.T) {
output := balanceOutput.Bytes()
defer balanceOutput.Reset()
if err := json.Unmarshal(output, &balanceResponse); err != nil {
return fmt.Errorf("unmarshalling query response error: %w, response: %s", err, string(output))
return errors.Errorf("unmarshalling query response error: %w, response: %s", err, string(output))
}
if balanceResponse.Balances.Empty() {
return fmt.Errorf("empty balances")
return errors.Errorf("empty balances")
}
if !strings.HasPrefix(balanceResponse.Balances[0].Denom, "ibc/") {
return fmt.Errorf("invalid ibc balance: %v", balanceResponse.Balances[0])
return errors.Errorf("invalid ibc balance: %v", balanceResponse.Balances[0])
}

return nil
Expand Down

0 comments on commit fd5d841

Please sign in to comment.