refactor(client): add client/Context.Codec and deprecate JSONCodec (#9498)
* chore(types): add sdk.Context.Codec and deprecate JSONCodec * Use clientContext.Codec rather than JSONCodec everywhere * update tests to use clientContext.Codec * added a note that EncodingConfig.Marshaler will be renamed to Codec * update changelog * fix tests to use clientCtx.WithCodec instead of WithJSONCodec * fix genutil build * Update simapp/params/encoding.go Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
This commit is contained in:
@@ -57,7 +57,7 @@ func (s IntegrationTestSuite) TestQueryNodeInfo() {
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/node_info", val.APIAddress))
|
||||
s.Require().NoError(err)
|
||||
var getInfoRes tmservice.GetNodeInfoResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &getInfoRes))
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &getInfoRes))
|
||||
s.Require().Equal(getInfoRes.ApplicationVersion.AppName, version.NewInfo().AppName)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (s IntegrationTestSuite) TestQuerySyncing() {
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/syncing", val.APIAddress))
|
||||
s.Require().NoError(err)
|
||||
var syncingRes tmservice.GetSyncingResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &syncingRes))
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &syncingRes))
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestQueryLatestBlock() {
|
||||
@@ -82,7 +82,7 @@ func (s IntegrationTestSuite) TestQueryLatestBlock() {
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/latest", val.APIAddress))
|
||||
s.Require().NoError(err)
|
||||
var blockInfoRes tmservice.GetLatestBlockResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &blockInfoRes))
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestQueryBlockByHeight() {
|
||||
@@ -93,7 +93,7 @@ func (s IntegrationTestSuite) TestQueryBlockByHeight() {
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/%d", val.APIAddress, 1))
|
||||
s.Require().NoError(err)
|
||||
var blockInfoRes tmservice.GetBlockByHeightResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &blockInfoRes))
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestQueryLatestValidatorSet() {
|
||||
@@ -124,7 +124,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() {
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/latest?pagination.offset=%d&pagination.limit=%d", val.APIAddress, 0, 1))
|
||||
s.Require().NoError(err)
|
||||
var validatorSetRes tmservice.GetLatestValidatorSetResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &validatorSetRes))
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &validatorSetRes))
|
||||
s.Require().Equal(1, len(validatorSetRes.Validators))
|
||||
anyPub, err := codectypes.NewAnyWithValue(val.PubKey)
|
||||
s.Require().NoError(err)
|
||||
@@ -183,7 +183,7 @@ func (s IntegrationTestSuite) TestLatestValidatorSet_GRPCGateway() {
|
||||
s.Require().Contains(string(res), tc.expErrMsg)
|
||||
} else {
|
||||
var result tmservice.GetLatestValidatorSetResponse
|
||||
err = vals[0].ClientCtx.JSONCodec.UnmarshalJSON(res, &result)
|
||||
err = vals[0].ClientCtx.Codec.UnmarshalJSON(res, &result)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(uint64(len(vals)), result.Pagination.Total)
|
||||
anyPub, err := codectypes.NewAnyWithValue(vals[0].PubKey)
|
||||
@@ -245,7 +245,7 @@ func (s IntegrationTestSuite) TestValidatorSetByHeight_GRPCGateway() {
|
||||
s.Require().Contains(string(res), tc.expErrMsg)
|
||||
} else {
|
||||
var result tmservice.GetValidatorSetByHeightResponse
|
||||
err = vals[0].ClientCtx.JSONCodec.UnmarshalJSON(res, &result)
|
||||
err = vals[0].ClientCtx.Codec.UnmarshalJSON(res, &result)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(uint64(len(vals)), result.Pagination.Total)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user