Skip to content

Commit

Permalink
remove MakeTestCodecs
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Jan 4, 2021
1 parent 1dca29a commit 6877082
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
+ added `overwriteSig` argument to `x/auth/client.SignTx` and `client/tx.Sign` functions.
+ removed `x/auth/tx.go:wrapper.GetSignatures`. The `wrapper` provides `TxBuilder` functionality, and it's a private
structure. That function was not used at all and it's not exposed through the `TxBuilder` interface.
* [\#8245](https://github.com/cosmos/cosmos-sdk/pull/8245) Marked deprecated `simapp.MakeCodecs` and renamed to `MakeTestCodecs`.
* [\#8245](https://github.com/cosmos/cosmos-sdk/pull/8245) Removed `simapp.MakeCodecs` and use `simapp.MakeTestEncodingConfig` instead.


### Bug Fixes
Expand Down
3 changes: 1 addition & 2 deletions codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) {
func TestAminoCodecFullDecodeAndEncode(t *testing.T) {
// This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117.
txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"cosmos14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"cosmosvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"tendermint/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}`
_, legacyCdc := simapp.MakeTestCodecs()

var legacyCdc = simapp.MakeTestEncodingConfig().Amino
var tx legacytx.StdTx
err := legacyCdc.UnmarshalJSON([]byte(txSigned), &tx)
require.NoError(t, err)
Expand Down
14 changes: 2 additions & 12 deletions simapp/encoding.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package simapp

import (
"github.com/cosmos/cosmos-sdk/codec"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing.
// This function should be used only internally (in the SDK).
// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
// should be used only in tests or when creating a new app instance (NewApp*()).
// App user shouldn't create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() simappparams.EncodingConfig {
Expand All @@ -18,12 +17,3 @@ func MakeTestEncodingConfig() simappparams.EncodingConfig {
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}

// MakeTestCodecs is a helper function which uses MakeTestEncodingConfig to
// construct new *std.Codec and *codec.LegacyAmino instances.
// It must not be used in non test files, instead app.AppCodec should be used.
// [DEPRECATED]
func MakeTestCodecs() (codec.Marshaler, *codec.LegacyAmino) {
config := MakeTestEncodingConfig()
return config.Marshaler, config.Amino
}
2 changes: 1 addition & 1 deletion 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.MakeTestCodecs()
appCodec := simapp.MakeTestEncodingConfig().Marshaler
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (suite *AnteTestSuite) TestSetPubKey() {
func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() {
params := types.DefaultParams()
msg := []byte{1, 2, 3, 4}
_, cdc := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Amino

pkSet1, sigSet1 := generatePubKeysAndSignatures(5, msg, false)
multisigKey1 := kmultisig.NewLegacyAminoPubKey(2, pkSet1)
Expand Down
2 changes: 1 addition & 1 deletion x/auth/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestSupply_ValidatePermissions(t *testing.T) {
maccPerms[multiPerm] = []string{types.Burner, types.Minter, types.Staking}
maccPerms[randomPerm] = []string{"random"}

cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
keeper := keeper.NewAccountKeeper(
cdc, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName),
types.ProtoBaseAccount, maccPerms,
Expand Down
2 changes: 1 addition & 1 deletion x/auth/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (

func TestDecodeStore(t *testing.T) {
app := simapp.Setup(false)
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
acc := types.NewBaseAccountWithAddress(delAddr1)
dec := simulation.NewDecodeStore(app.AccountKeeper)

Expand Down
3 changes: 2 additions & 1 deletion x/auth/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import (

var (
app = simapp.Setup(false)
appCodec, legacyAmino = simapp.MakeTestCodecs()
ecdc = simapp.MakeTestEncodingConfig()
appCodec, legacyAmino = ecdc.Marshaler, ecdc.Amino
)
4 changes: 2 additions & 2 deletions x/auth/vesting/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import (
)

var (
app = simapp.Setup(false)
appCodec, _ = simapp.MakeTestCodecs()
app = simapp.Setup(false)
appCodec = simapp.MakeTestEncodingConfig().Marshaler
)
2 changes: 1 addition & 1 deletion x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() {
func (suite *IntegrationTestSuite) TestSupply_BurnCoins() {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1})
appCodec, _ := simapp.MakeTestCodecs()
appCodec := simapp.MakeTestEncodingConfig().Marshaler

// add module accounts to supply keeper
maccPerms := simapp.GetMaccPerms()
Expand Down
2 changes: 1 addition & 1 deletion x/capability/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestDecodeStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

capOwners := types.CapabilityOwners{
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
)

func TestDecodeDistributionStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

decCoins := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.OneDec())}
Expand Down
12 changes: 6 additions & 6 deletions x/evidence/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ const (
func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_Existing() {
ctx := suite.ctx.WithIsCheckTx(false)
numEvidence := 100
_, cdc := simapp.MakeTestCodecs()
legacyCdc := simapp.MakeTestEncodingConfig().Amino

evidence := suite.populateEvidence(ctx, numEvidence)
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryEvidenceRequest(evidence[0].Hash())),
Data: legacyCdc.MustMarshalJSON(types.NewQueryEvidenceRequest(evidence[0].Hash())),
}

bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query)
suite.Nil(err)
suite.NotNil(bz)

var e exported.Evidence
suite.Nil(cdc.UnmarshalJSON(bz, &e))
suite.Nil(legacyCdc.UnmarshalJSON(bz, &e))
suite.Equal(evidence[0], e)
}

func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() {
ctx := suite.ctx.WithIsCheckTx(false)
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
numEvidence := 100

suite.populateEvidence(ctx, numEvidence)
Expand All @@ -53,7 +53,7 @@ func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() {

func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence() {
ctx := suite.ctx.WithIsCheckTx(false)
_, cdc := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Amino
numEvidence := 100

suite.populateEvidence(ctx, numEvidence)
Expand All @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence() {

func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence_InvalidPagination() {
ctx := suite.ctx.WithIsCheckTx(false)
_, cdc := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Amino
numEvidence := 100

suite.populateEvidence(ctx, numEvidence)
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
pks := simapp.CreateTestPubKeys(5)
cdc := simapp.MakeTestEncodingConfig().Marshaler

appCodec, _ := simapp.MakeTestCodecs()
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
cdc,
app.GetKey(stakingtypes.StoreKey),
app.AccountKeeper,
app.BankKeeper,
Expand Down
3 changes: 1 addition & 2 deletions x/gov/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ var (
)

func TestDecodeStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

endTime := time.Now().UTC()

content := types.ContentFromProposalType("test", "test", types.ProposalTypeText)
proposal, err := types.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour))
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion x/mint/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestDecodeStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15))
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
)

func TestDecodeStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

info := types.NewValidatorSigningInfo(consAddr1, 0, 1, time.Now().UTC(), false, 0)
Expand Down
5 changes: 2 additions & 3 deletions x/staking/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,9 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.TokensFromConsensusPower(300))
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
pks := simapp.CreateTestPubKeys(5)

appCodec, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
app.StakingKeeper = keeper.NewKeeper(
appCodec,
cdc,
app.GetKey(types.StoreKey),
app.AccountKeeper,
app.BankKeeper,
Expand Down
3 changes: 1 addition & 2 deletions x/staking/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ func makeTestCodec() (cdc *codec.LegacyAmino) {
}

func TestDecodeStore(t *testing.T) {
cdc, _ := simapp.MakeTestCodecs()
cdc := simapp.MakeTestEncodingConfig().Marshaler
dec := simulation.NewDecodeStore(cdc)

bondTime := time.Now().UTC()

val, err := types.NewValidator(valAddr1, delPk1, types.NewDescription("test", "test", "test", "test", "test"))
Expand Down

0 comments on commit 6877082

Please sign in to comment.