From 44f7af6c5b157e2365cb6e53d99b738dbffa47e7 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 30 Sep 2024 07:40:13 +0200 Subject: [PATCH] chore(server/v2/cometbft): improve code check (#21955) (cherry picked from commit 7c6e0388a3f92573a5a750f015b56f3f6105417c) # Conflicts: # server/v2/cometbft/go.mod --- server/v2/cometbft/abci.go | 5 +++-- server/v2/cometbft/go.mod | 10 ++++++++++ tests/systemtests/bank_test.go | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index 85b38e4ccc65..02966c874770 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -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" @@ -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 } @@ -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 diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 74afb1071101..314eb41240be 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -16,9 +16,16 @@ replace ( ) require ( +<<<<<<< HEAD cosmossdk.io/api v0.8.0 cosmossdk.io/core v1.0.0 // main cosmossdk.io/errors v1.0.1 // indirect +======= + 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 +>>>>>>> 7c6e0388a (chore(server/v2/cometbft): improve code check (#21955)) cosmossdk.io/log v1.4.1 cosmossdk.io/server/v2 v2.0.0-20240927165321-7fe95fc3f945 // main cosmossdk.io/server/v2/appmanager v0.0.0-20240920095614-aa90bb43d8f8 // main @@ -39,7 +46,10 @@ 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 +<<<<<<< HEAD cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect +======= +>>>>>>> 7c6e0388a (chore(server/v2/cometbft): improve code check (#21955)) cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/math v1.3.0 // indirect diff --git a/tests/systemtests/bank_test.go b/tests/systemtests/bank_test.go index ae654fcba457..2e028728566a 100644 --- a/tests/systemtests/bank_test.go +++ b/tests/systemtests/bank_test.go @@ -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