Skip to content

Commit

Permalink
EncodingConfig.Marshaller -> EncodingConfig.Codec
Browse files Browse the repository at this point in the history
  • Loading branch information
catShaark committed Dec 7, 2022
1 parent a4ec866 commit 5a8462b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestMsgSendTxValidateBasic(t *testing.T) {
Amount: ibctesting.TestCoins,
}

data, err := icatypes.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, []proto.Message{msgBankSend})
data, err := icatypes.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, []proto.Message{msgBankSend})
require.NoError(t, err)

packetData := icatypes.InterchainAccountPacketData{
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestMsgSendTxGetSigners(t *testing.T) {
Amount: ibctesting.TestCoins,
}

data, err := icatypes.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, []proto.Message{msgBankSend})
data, err := icatypes.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, []proto.Message{msgBankSend})
require.NoError(t, err)

packetData := icatypes.InterchainAccountPacketData{
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/27-interchain-accounts/types/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() {
tc := tc

suite.Run(tc.name, func() {
bz, err := types.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, tc.msgs)
bz, err := types.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, tc.msgs)
suite.Require().NoError(err, tc.name)

msgs, err := types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, bz)
msgs, err := types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, bz)
if tc.expPass {
suite.Require().NoError(err, tc.name)
} else {
Expand All @@ -131,16 +131,16 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() {
}

// test serializing non sdk.Msg type
bz, err := types.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, []proto.Message{&banktypes.MsgSendResponse{}})
bz, err := types.SerializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, []proto.Message{&banktypes.MsgSendResponse{}})
suite.Require().NoError(err)
suite.Require().NotEmpty(bz)

// test deserializing unknown bytes
_, err = types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, bz)
_, err = types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, bz)
suite.Require().Error(err) // unregistered type

// test deserializing unknown bytes
msgs, err := types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Marshaler, []byte("invalid"))
msgs, err := types.DeserializeCosmosTx(simapp.MakeTestEncodingConfig().Codec, []byte("invalid"))
suite.Require().Error(err)
suite.Require().Empty(msgs)
}
Expand Down
4 changes: 2 additions & 2 deletions testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) {
appOptions[flags.FlagHome] = simapp.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = 5
app := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, appOptions)
return app, simapp.NewDefaultGenesisState(encCdc.Marshaler)
return app, simapp.NewDefaultGenesisState(encCdc.Codec)
}
```

Expand Down Expand Up @@ -265,7 +265,7 @@ func SetupTransferTestingApp() (ibctesting.TestingApp, map[string]json.RawMessag
appOptions[flags.FlagHome] = simapp.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = 5
app := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, appOptions)
return app, simapp.NewDefaultGenesisState(encCdc.Marshaler)
return app, simapp.NewDefaultGenesisState(encCdc.Codec)
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) {
appOptions[flags.FlagHome] = simapp.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = 5
app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, appOptions)
return app, simapp.NewDefaultGenesisState(encCdc.Marshaler)
return app, simapp.NewDefaultGenesisState(encCdc.Codec)
}

// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts
Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func NewSimApp(
homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig,
appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
) *SimApp {
appCodec := encodingConfig.Marshaler
appCodec := encodingConfig.Codec
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry

Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/params/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
Codec codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
6 changes: 3 additions & 3 deletions testing/simapp/params/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
func MakeTestEncodingConfig() EncodingConfig {
cdc := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
codec := codec.NewProtoCodec(interfaceRegistry)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
Codec: codec,
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
Amino: cdc,
}
}
2 changes: 1 addition & 1 deletion testing/simapp/simd/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
require.NoError(t, err)

appCodec := simapp.MakeTestEncodingConfig().Marshaler
appCodec := simapp.MakeTestEncodingConfig().Codec
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions testing/simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
encodingConfig := simapp.MakeTestEncodingConfig()
initClientCtx := client.Context{}.
WithCodec(encodingConfig.Marshaler).
WithCodec(encodingConfig.Codec).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
Expand Down Expand Up @@ -185,7 +185,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
)

// add rosetta
// rootCmd.AddCommand(server.Rosett(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
// rootCmd.AddCommand(server.Rosett(encodingConfig.InterfaceRegistry, encodingConfig.Codec))
}

func addModuleInitFlags(startCmd *cobra.Command) {
Expand Down

0 comments on commit 5a8462b

Please sign in to comment.