diff --git a/modules/light-clients/08-wasm/keeper/grpc_query_test.go b/modules/light-clients/08-wasm/keeper/grpc_query_test.go index a54cc20f616..047e16a88c5 100644 --- a/modules/light-clients/08-wasm/keeper/grpc_query_test.go +++ b/modules/light-clients/08-wasm/keeper/grpc_query_test.go @@ -6,6 +6,10 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + errorsmod "cosmossdk.io/errors" wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing" "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" ) @@ -16,7 +20,7 @@ func (suite *KeeperTestSuite) TestQueryCode() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", @@ -29,21 +33,27 @@ func (suite *KeeperTestSuite) TestQueryCode() { req = &types.QueryCodeRequest{Checksum: hex.EncodeToString(res.Checksum)} }, - true, + nil, }, { "fails with empty request", func() { req = &types.QueryCodeRequest{} }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrap(types.ErrWasmChecksumNotFound, "").Error(), + ), }, { "fails with non-existent checksum", func() { req = &types.QueryCodeRequest{Checksum: "test"} }, - false, + status.Error( + codes.InvalidArgument, + types.ErrInvalidChecksum.Error(), + ), }, } @@ -55,12 +65,13 @@ func (suite *KeeperTestSuite) TestQueryCode() { res, err := GetSimApp(suite.chainA).WasmClientKeeper.Code(suite.chainA.GetContext(), req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().NotEmpty(res.Data) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -72,14 +83,14 @@ func (suite *KeeperTestSuite) TestQueryChecksums() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success with no checksums", func() { expChecksums = []string{} }, - true, + nil, }, { "success with one checksum", @@ -92,7 +103,7 @@ func (suite *KeeperTestSuite) TestQueryChecksums() { expChecksums = append(expChecksums, hex.EncodeToString(res.Checksum)) }, - true, + nil, }, } @@ -105,7 +116,7 @@ func (suite *KeeperTestSuite) TestQueryChecksums() { req := &types.QueryChecksumsRequest{} res, err := GetSimApp(suite.chainA).WasmClientKeeper.Checksums(suite.chainA.GetContext(), req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(len(expChecksums), len(res.Checksums))