Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server/v2/cometbft): improve code check #21955

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
gogoproto "github.com/cosmos/gogoproto/proto"

"cosmossdk.io/collections"
"cosmossdk.io/core/comet"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/event"
Expand Down Expand Up @@ -123,7 +124,7 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques

resp, err := c.app.ValidateTx(ctx, decodedTx)
// we do not want to return a cometbft error, but a check tx response with the error
if err != nil && err != resp.Error {
if err != nil && !errors.Is(err, resp.Error) {
return nil, err
}

Expand Down Expand Up @@ -161,7 +162,7 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc
cp, err := c.GetConsensusParams(ctx)
// if the consensus params are not found, we set the app version to 0
// in the case that the start version is > 0
if cp == nil || errors.Is(err, errors.New("collections: not found")) {
if cp == nil || errors.Is(err, collections.ErrNotFound) {
appVersion = 0
} else if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ replace (

require (
cosmossdk.io/api v0.7.6
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v1.0.0-alpha.3
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
cosmossdk.io/log v1.4.1
Expand All @@ -41,7 +42,6 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
Expand Down
2 changes: 1 addition & 1 deletion tests/systemtests/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestBankSendTxCmd(t *testing.T) {
require.Len(t, gotOutputs, 1)
code := gjson.Get(gotOutputs[0].(string), "code")
require.True(t, code.Exists())
require.Equal(t, int64(sdkerrors.ErrUnauthorized.ABCICode()), code.Int())
require.Greater(t, code.Int(), int64(0))
return false
}
invalidCli := cli
Expand Down
Loading