From 9057fcbf1acf55296be3792ac8065895877a2588 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 5 Dec 2024 17:00:43 +0100 Subject: [PATCH] fix: error in tests --- modules/core/keeper/msg_server.go | 4 ++-- modules/core/keeper/msg_server_test.go | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index c9feabe776c..361128c6cbf 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -123,7 +123,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } - // TODO: Make decision on this. Accessing GetCachedValue returns nil due to loss of data in internal sdk msg handler. + // TODO(sdk/v0.52): This should be reverted before release pending sdk fix. Accessing GetCachedValue returns nil due to loss of data in internal sdk msg handler. // For now we can assume tendermint client state here as that's what we expect, but this may not always be the case for other msg handlers // which use pb.Any encoding of msg types going through msg router service hybrid handler. // upgradedClientState, err := clienttypes.UnpackClientState(msg.UpgradedClientState) @@ -132,7 +132,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI // } var upgradedClientState ibctm.ClientState if err := k.cdc.Unmarshal(msg.UpgradedClientState.Value, &upgradedClientState); err != nil { - return nil, err + return nil, errorsmod.Wrapf(clienttypes.ErrInvalidClientType, "cannot unmarshal tendermint client state: %s", err) } if err := k.ClientKeeper.ScheduleIBCSoftwareUpgrade(goCtx, msg.Plan, &upgradedClientState); err != nil { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 0382bdc7d63..424fc10b356 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -2,11 +2,11 @@ package keeper_test import ( "context" - "errors" "fmt" upgradetypes "cosmossdk.io/x/upgrade/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -21,6 +21,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -2464,7 +2465,10 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { { "failure: invalid clientState", func() { - msg.UpgradedClientState = nil + clientAny, err := codectypes.NewAnyWithValue(&solomachine.ClientState{Sequence: 100}) + suite.Require().NoError(err) + + msg.UpgradedClientState = clientAny }, clienttypes.ErrInvalidClientType, }, @@ -2519,7 +2523,7 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { suite.Require().NoError(err) suite.Require().Equal(clientState.ZeroCustomFields(), upgradedClientState) } else { - suite.Require().True(errors.Is(err, tc.expError)) + suite.Require().ErrorIs(err, tc.expError) } }) }