refactor!: remove global config from x/auth and client (#19447)

This commit is contained in:
Julián Toledano 2024-03-06 14:14:16 +01:00 committed by GitHub
parent 06a398931e
commit 25aea8af8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
140 changed files with 572 additions and 300 deletions

View File

@ -96,6 +96,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### API Breaking Changes
* (types) [#19447](https://github.com/cosmos/cosmos-sdk/pull/19447) `module.testutil.MakeTestEncodingConfig` now takes `CodecOptions` as argument.
* (types) [#19512](https://github.com/cosmos/cosmos-sdk/pull/19512) Remove basic manager and all related functions (`module.BasicManager`, `module.NewBasicManager`, `module.NewBasicManagerFromManager`, `NewGenesisOnlyAppModule`).
* The module manager now can do everything that the basic manager was doing.
* When using runtime, just inject the module manager when needed using your app config.

View File

@ -12,16 +12,19 @@ In this section we describe the changes made in Cosmos SDK' SimApp.
#### Client (`root.go`)
The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.).
The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.)
and address bech32 prefixes (address and validator address).
This is part of the work of abstracting the SDK from the global bech32 config.
This means the address codecs must be provided in the `client.Context` in the application client (usually `root.go`).
This means the address codecs and prefixes must be provided in the `client.Context` in the application client (usually `root.go`).
```diff
clientCtx = clientCtx.
+ WithAddressCodec(addressCodec).
+ WithValidatorAddressCodec(validatorAddressCodec).
+ WithConsensusAddressCodec(consensusAddressCodec)
+ WithConsensusAddressCodec(consensusAddressCodec).
+ WithAddressPrefix("cosmos").
+ WithValidatorPrefix("cosmosvaloper")
```
**When using `depinject` / `app v2`, the client codecs can be provided directly from application config.**

View File

@ -469,9 +469,10 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection()
// create a codec for marshaling
cdc := codectestutil.CodecOptions{}.NewCodec()
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())
signingCtx := cdc.InterfaceRegistry().SigningContext()
// create a baseapp along with a tx config for tx generation
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
app := baseapp.NewBaseApp(s.T().Name(), log.NewNopLogger(), dbm.NewMemDB(), txConfig.TxDecoder())
// create a proposal handler
@ -566,7 +567,8 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection()
func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSelection() {
cdc := codectestutil.CodecOptions{}.NewCodec()
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
signingCtx := cdc.InterfaceRegistry().SigningContext()
txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
var (
secret1 = []byte("secret1")

View File

@ -29,7 +29,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -65,8 +64,9 @@ func NewBaseAppSuite(t *testing.T, opts ...func(*baseapp.BaseApp)) *BaseAppSuite
t.Helper()
cdc := codectestutil.CodecOptions{}.NewCodec()
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())
signingCtx := cdc.InterfaceRegistry().SigningContext()
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
db := dbm.NewMemDB()
logBuffer := new(bytes.Buffer)
logger := log.NewLogger(logBuffer, log.ColorOption(false))
@ -499,11 +499,12 @@ func TestBaseAppOptionSeal(t *testing.T) {
}
func TestTxDecoder(t *testing.T) {
cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
cdc := codectestutil.CodecOptions{}.NewCodec()
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())
signingCtx := cdc.InterfaceRegistry().SigningContext()
// patch in TxConfig instead of using an output from x/auth/tx
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
tx := newTxCounter(t, txConfig, 1, 0)
txBytes, err := txConfig.TxEncoder()(tx)

View File

@ -136,9 +136,10 @@ func TestMsgService(t *testing.T) {
), &appBuilder, &cdc, &interfaceRegistry)
require.NoError(t, err)
app := appBuilder.Build(dbm.NewMemDB(), nil)
signingCtx := interfaceRegistry.SigningContext()
// patch in TxConfig instead of using an output from x/auth/tx
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
// set the TxDecoder in the BaseApp for minimal tx simulations
app.SetTxDecoder(txConfig.TxDecoder())

View File

@ -79,6 +79,10 @@ type Context struct {
AddressCodec address.Codec
ValidatorAddressCodec address.Codec
ConsensusAddressCodec address.Codec
// Bech32 address prefixes.
AddressPrefix string
ValidatorPrefix string
}
// WithCmdContext returns a copy of the context with an updated context.Context,
@ -337,6 +341,18 @@ func (ctx Context) WithConsensusAddressCodec(consensusAddressCodec address.Codec
return ctx
}
// WithAddressPrefix returns the context with the provided address bech32 prefix.
func (ctx Context) WithAddressPrefix(addressPrefix string) Context {
ctx.AddressPrefix = addressPrefix
return ctx
}
// WithValidatorPrefix returns the context with the provided validator bech32 prefix.
func (ctx Context) WithValidatorPrefix(validatorPrefix string) Context {
ctx.ValidatorPrefix = validatorPrefix
return ctx
}
// PrintString prints the raw string to ctx.Output if it's defined, otherwise to os.Stdout
func (ctx Context) PrintString(str string) error {
return ctx.PrintBytes([]byte(str))

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@ -98,7 +99,7 @@ x: "10"
}
func TestGetFromFields(t *testing.T) {
cfg := testutil.MakeTestEncodingConfig()
cfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
path := hd.CreateHDPath(118, 0, 0).String()
testCases := []struct {

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
@ -39,7 +40,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
keys := storetypes.NewKVStoreKeys(countertypes.StoreKey)
cms := integration.CreateMultiStore(keys, logger)
s.ctx = sdk.NewContext(cms, true, logger)
cfg := moduletestutil.MakeTestEncodingConfig(counter.AppModule{})
cfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, counter.AppModule{})
s.cdc = cfg.Codec
queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, cfg.InterfaceRegistry)

View File

@ -269,7 +269,7 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
// If we're using ledger, only thing we need is the path and the bech32 prefix.
if useLedger {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()
bech32PrefixAccAddr := ctx.AddressPrefix
k, err := kb.SaveLedgerKey(name, hd.Secp256k1, bech32PrefixAccAddr, coinType, account, index)
if err != nil {
return err

View File

@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -39,7 +40,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
// Prepare a keybase
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
clientCtx := client.Context{}.
WithKeyringDir(kbHome).
WithCodec(cdc).
@ -97,7 +98,7 @@ func Test_runAddCmdLedger(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
clientCtx := client.Context{}.
WithKeyringDir(kbHome).
@ -144,7 +145,7 @@ func Test_runAddCmdLedger(t *testing.T) {
}
func Test_runAddCmdLedgerDryRun(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
testData := []struct {
name string
args []string

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -28,7 +29,7 @@ func Test_runAddCmdBasic(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)
@ -149,7 +150,7 @@ func Test_runAddCmdMultisigDupKeys(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)
@ -217,7 +218,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
pubkey1 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtObiFVE4s+9+RX5SP8TN9r2mxpoaT4eGj9CJfK7VRzN"}`
pubkey2 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/se1vkqgdQ7VJQCM4mxN+L+ciGhnnJ4XYsQCRBMrdRi"}`
b64Pubkey := "QWhnOHhpdXBJcGZ2UlR2ak5la1ExclROUThTOW96YjdHK2RYQmFLVjl4aUo="
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
testData := []struct {
name string
@ -349,7 +350,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
func TestAddRecoverFileBackend(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands().PersistentFlags())
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()

View File

@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -34,7 +35,7 @@ func Test_runDeleteCmd(t *testing.T) {
fakeKeyName2 := "runDeleteCmd_Key2"
path := sdk.GetFullBIP44Path()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
cmd.SetArgs([]string{"blah", fmt.Sprintf("--%s=%s", flags.FlagKeyringDir, kbHome)})
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -19,7 +20,7 @@ import (
)
func Test_runExportCmd(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
testCases := []struct {
name string
keyringBackend string

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -18,7 +19,7 @@ import (
)
func Test_runImportCmd(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
testCases := []struct {
name string
keyringBackend string
@ -122,7 +123,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO
}
func Test_runImportHexCmd(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
testCases := []struct {
name string
keyringBackend string
@ -184,7 +185,7 @@ func Test_runImportCmdWithEmptyName(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
// Now add a temporary keybase
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -39,7 +40,7 @@ func Test_runListCmd(t *testing.T) {
kbHome2 := t.TempDir()
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome2, mockIn, cdc)
assert.NilError(t, err)
@ -92,7 +93,7 @@ func Test_runListCmd(t *testing.T) {
func Test_runListKeyTypeCmd(t *testing.T) {
cmd := ListKeyTypesCmd()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kbHome := t.TempDir()
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@ -41,7 +42,7 @@ func TestMigrateTestSuite(t *testing.T) {
func (s *MigrateTestSuite) SetupSuite() {
s.dir = s.T().TempDir()
s.cdc = moduletestutil.MakeTestEncodingConfig().Codec
s.cdc = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
s.appName = "cosmos"
s.priv = cryptotypes.PrivKey(secp256k1.GenPrivKey())
s.pub = s.priv.PubKey()

View File

@ -11,19 +11,20 @@ import (
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
)
func bech32Prefixes(config *sdk.Config) []string {
func bech32Prefixes(mainBech32Prefix string) []string {
return []string{
config.GetBech32AccountAddrPrefix(),
config.GetBech32AccountPubPrefix(),
config.GetBech32ValidatorAddrPrefix(),
config.GetBech32ValidatorPubPrefix(),
config.GetBech32ConsensusAddrPrefix(),
config.GetBech32ConsensusPubPrefix(),
mainBech32Prefix,
sdk.GetBech32PrefixAccPub(mainBech32Prefix),
sdk.GetBech32PrefixValAddr(mainBech32Prefix),
sdk.GetBech32PrefixValPub(mainBech32Prefix),
sdk.GetBech32PrefixConsAddr(mainBech32Prefix),
sdk.GetBech32PrefixConsPub(mainBech32Prefix),
}
}
@ -44,8 +45,8 @@ type bech32Output struct {
Formats []string `json:"formats"`
}
func newBech32Output(config *sdk.Config, bs []byte) bech32Output {
bech32Prefixes := bech32Prefixes(config)
func newBech32Output(bech32Prefix string, bs []byte) bech32Output {
bech32Prefixes := bech32Prefixes(bech32Prefix)
out := bech32Output{Formats: make([]string, len(bech32Prefixes))}
for i, prefix := range bech32Prefixes {
@ -80,15 +81,18 @@ hexadecimal into bech32 cosmos prefixed format and vice versa.
`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
config, _ := sdk.GetSealedConfig(cmd.Context())
return doParseKey(cmd, config, args)
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
return doParseKey(cmd, clientCtx.AddressPrefix, args)
},
}
return cmd
}
func doParseKey(cmd *cobra.Command, config *sdk.Config, args []string) error {
func doParseKey(cmd *cobra.Command, bech32Prefix string, args []string) error {
addr := strings.TrimSpace(args[0])
outstream := cmd.OutOrStdout()
@ -97,7 +101,7 @@ func doParseKey(cmd *cobra.Command, config *sdk.Config, args []string) error {
}
output, _ := cmd.Flags().GetString(flags.FlagOutput)
if !(runFromBech32(outstream, addr, output) || runFromHex(config, outstream, addr, output)) {
if !(runFromBech32(outstream, addr, output) || runFromHex(bech32Prefix, outstream, addr, output)) {
return errors.New("couldn't find valid bech32 nor hex data")
}
@ -117,13 +121,13 @@ func runFromBech32(w io.Writer, bech32str, output string) bool {
}
// print info from hex
func runFromHex(config *sdk.Config, w io.Writer, hexstr, output string) bool {
func runFromHex(bech32Prefix string, w io.Writer, hexstr, output string) bool {
bz, err := hex.DecodeString(hexstr)
if err != nil {
return false
}
displayParseKeyInfo(w, newBech32Output(config, bz), output)
displayParseKeyInfo(w, newBech32Output(bech32Prefix, bz), output)
return true
}

View File

@ -4,16 +4,12 @@ import (
"testing"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestParseKey(t *testing.T) {
bech32str := "cosmos104ytdpvrx9284zd50v9ep8c6j7pua7dkk0x3ek"
hexstr := "EB5AE9872103497EC092EF901027049E4F39200C60040D3562CD7F104A39F62E6E5A39A818F4"
config := sdk.NewConfig()
tests := []struct {
name string
args []string
@ -27,7 +23,7 @@ func TestParseKey(t *testing.T) {
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), config, tt.args) != nil)
require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), "cosmos", tt.args) != nil)
})
}
}

View File

@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -33,7 +34,7 @@ func Test_runRenameCmd(t *testing.T) {
path := sdk.GetFullBIP44Path()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

View File

@ -175,7 +175,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
return err
}
return ledger.ShowAddress(*ledgerItem.Path, pk, sdk.GetConfig().GetBech32AccountAddrPrefix())
return ledger.ShowAddress(*ledgerItem.Path, pk, clientCtx.AddressPrefix)
}
return nil

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
@ -56,7 +57,7 @@ func Test_runShowCmd(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
cdc := moduletestutil.MakeTestEncodingConfig().Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

View File

@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
@ -33,7 +34,7 @@ var (
func TestAuxTxBuilder(t *testing.T) {
counterModule := counter.AppModule{}
cdc := moduletestutil.MakeTestEncodingConfig(counterModule).Codec
cdc := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, counterModule).Codec
reg := codectypes.NewInterfaceRegistry()
testdata.RegisterInterfaces(reg)

View File

@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@ -28,8 +29,10 @@ import (
)
func newTestTxConfig() (client.TxConfig, codec.Codec) {
encodingConfig := moduletestutil.MakeTestEncodingConfig()
return authtx.NewTxConfig(codec.NewProtoCodec(encodingConfig.InterfaceRegistry), authtx.DefaultSignModes), encodingConfig.Codec
encodingConfig := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{})
cdc := codec.NewProtoCodec(encodingConfig.InterfaceRegistry)
signingCtx := encodingConfig.InterfaceRegistry.SigningContext()
return authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), encodingConfig.Codec
}
// mockContext is a mock client.Context to return arbitrary simulation response, used to
@ -153,7 +156,7 @@ func TestBuildUnsignedTx(t *testing.T) {
}
func TestBuildUnsignedTxWithWithExtensionOptions(t *testing.T) {
txCfg := moduletestutil.MakeBuilderTestTxConfig()
txCfg := moduletestutil.MakeBuilderTestTxConfig(testutil.CodecOptions{})
extOpts := []*codectypes.Any{
{
TypeUrl: "/test",

View File

@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/testutil"
sdkkeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -51,7 +52,7 @@ func initFixture(t *testing.T) *fixture {
clientConn, err := grpc.Dial(listener.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
assert.NilError(t, err)
encodingConfig := moduletestutil.MakeTestEncodingConfig(bank.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, bank.AppModule{})
kr, err := sdkkeyring.New(sdk.KeyringServiceName(), sdkkeyring.BackendMemory, home, nil, encodingConfig.Codec)
assert.NilError(t, err)
@ -62,8 +63,8 @@ func initFixture(t *testing.T) *fixture {
banktypes.RegisterInterfaces(interfaceRegistry)
clientCtx := client.Context{}.
WithAddressCodec(addresscodec.NewBech32Codec("cosmos")).
WithValidatorAddressCodec(addresscodec.NewBech32Codec("cosmosvaloper")).
WithAddressCodec(interfaceRegistry.SigningContext().AddressCodec()).
WithValidatorAddressCodec(interfaceRegistry.SigningContext().ValidatorAddressCodec()).
WithConsensusAddressCodec(addresscodec.NewBech32Codec("cosmosvalcons")).
WithKeyring(kr).
WithKeyringDir(home).

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -71,7 +72,7 @@ func TestMarshalAny(t *testing.T) {
func TestMarshalProtoPubKey(t *testing.T) {
require := require.New(t)
ccfg := testutil.MakeTestEncodingConfig()
ccfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
privKey := ed25519.GenPrivKey()
pk := privKey.PubKey()
@ -111,7 +112,7 @@ func TestMarshalProtoPubKey(t *testing.T) {
// helper functions
func TestMarshalProtoInterfacePubKey(t *testing.T) {
require := require.New(t)
ccfg := testutil.MakeTestEncodingConfig()
ccfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
privKey := ed25519.GenPrivKey()
pk := privKey.PubKey()

View File

@ -3,6 +3,7 @@ package testutil
import (
"github.com/cosmos/gogoproto/proto"
coreaddress "cosmossdk.io/core/address"
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec"
@ -10,34 +11,45 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)
// CodecOptions are options for creating a test codec.
// CodecOptions are options for creating a test codec. If set, provided address codecs will be prioritized when
// building the InterfaceRegistry and ProtoCodec. If not set, new address bech32 codecs will be created using
// the provided prefixes.
type CodecOptions struct {
AccAddressPrefix string
ValAddressPrefix string
AddressCodec coreaddress.Codec
ValidatorCodec coreaddress.Codec
}
// NewCodecOptionsWithPrefixes returns CodecOptions with provided prefixes.
func NewCodecOptionsWithPrefixes(addressPrefix, validatorPrefix string) CodecOptions {
return CodecOptions{
AccAddressPrefix: addressPrefix,
ValAddressPrefix: validatorPrefix,
}
}
// NewCodecOptionsWithCodecs returns CodecOptions with provided address codecs.
func NewCodecOptionsWithCodecs(addressCodec, validatorCodec coreaddress.Codec) CodecOptions {
return CodecOptions{
AddressCodec: addressCodec,
ValidatorCodec: validatorCodec,
}
}
// NewInterfaceRegistry returns a new InterfaceRegistry with the given options.
func (o CodecOptions) NewInterfaceRegistry() codectypes.InterfaceRegistry {
accAddressPrefix := o.AccAddressPrefix
if accAddressPrefix == "" {
accAddressPrefix = "cosmos"
}
valAddressPrefix := o.ValAddressPrefix
if valAddressPrefix == "" {
valAddressPrefix = "cosmosvaloper"
}
ir, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: address.NewBech32Codec(accAddressPrefix),
ValidatorAddressCodec: address.NewBech32Codec(valAddressPrefix),
AddressCodec: o.GetAddressCodec(),
ValidatorAddressCodec: o.GetValidatorCodec(),
},
})
if err != nil {
panic(err)
}
return ir
}
@ -45,3 +57,33 @@ func (o CodecOptions) NewInterfaceRegistry() codectypes.InterfaceRegistry {
func (o CodecOptions) NewCodec() *codec.ProtoCodec {
return codec.NewProtoCodec(o.NewInterfaceRegistry())
}
// GetAddressCodec returns the address codec. If not address codec was provided it'll create a new one based on the
// bech32 prefix.
func (o CodecOptions) GetAddressCodec() coreaddress.Codec {
if o.AddressCodec != nil {
return o.AddressCodec
}
accAddressPrefix := o.AccAddressPrefix
if accAddressPrefix == "" {
accAddressPrefix = "cosmos"
}
return address.NewBech32Codec(accAddressPrefix)
}
// GetValidatorCodec returns the validator address codec. If not validator codec was provided it'll create a new one
// based on the bech32 prefix.
func (o CodecOptions) GetValidatorCodec() coreaddress.Codec {
if o.ValidatorCodec != nil {
return o.ValidatorCodec
}
valAddressPrefix := o.ValAddressPrefix
if valAddressPrefix == "" {
valAddressPrefix = "cosmosvaloper"
}
return address.NewBech32Codec(valAddressPrefix)
}

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
)
@ -14,7 +15,7 @@ import (
// protowire.ConsumeFieldValue. Discovered from fuzzing.
func TestBadBytesPassedIntoDecoder(t *testing.T) {
data, _ := hex.DecodeString("0A9F010A9C200A2D2F6962632E636F72652E636F6E6E656374696F6E2E76312E4D7367436F6E6E656374696F584F75656E496E6974126B0A0D6962637A65726F636C69656E74120B6962637A65726F636F6E6E1A1C0A0C6962636F6E65636C69656E74120A6962636F6E65636F6E6E00002205312E302E302A283235454635364341373935313335453430393336384536444238313130463232413442453035433212080A0612040A0208011A40143342993E25DA936CDDC7BE3D8F603CA6E9661518D536D0C482E18A0154AA096E438A6B9BCADFCFC2F0D689DCCAF55B96399D67A8361B70F5DA13091E2F929")
cfg := testutil.MakeTestEncodingConfig()
cfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
decoder := cfg.TxConfig.TxDecoder()
tx, err := decoder(data)

View File

@ -95,7 +95,7 @@ func TestPublicKeySafe(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, priv)
require.Nil(t, ShowAddress(path, priv.PubKey(), sdk.GetConfig().GetBech32AccountAddrPrefix()))
require.Nil(t, ShowAddress(path, priv.PubKey(), "cosmos"))
checkDefaultPubKey(t, priv)
addr2 := sdk.AccAddress(priv.PubKey().Address()).String()

View File

@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
@ -450,7 +451,7 @@ func TestEmptyMinGasPrices(t *testing.T) {
tempDir := t.TempDir()
err := os.Mkdir(filepath.Join(tempDir, "config"), os.ModePerm)
require.NoError(t, err)
encCfg := testutil.MakeTestEncodingConfig()
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
// Run InitCmd to create necessary config files.
clientCtx := client.Context{}.WithHomeDir(tempDir).WithCodec(encCfg.Codec)

View File

@ -207,7 +207,8 @@ func NewSimApp(
})
appCodec := codec.NewProtoCodec(interfaceRegistry)
legacyAmino := codec.NewLegacyAmino()
txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes)
signingCtx := interfaceRegistry.SigningContext()
txConfig := authtx.NewTxConfig(appCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
std.RegisterLegacyAminoCodec(legacyAmino)
std.RegisterInterfaces(interfaceRegistry)
@ -278,13 +279,11 @@ func NewSimApp(
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), logger), authtypes.NewModuleAddress(govtypes.ModuleName).String())
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
addressCodec := authcodec.NewBech32Codec(sdk.Bech32MainPrefix)
// add keepers
accountsKeeper, err := accounts.NewKeeper(
appCodec,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger),
addressCodec,
signingCtx.AddressCodec(),
appCodec,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
@ -300,7 +299,7 @@ func NewSimApp(
}
app.AccountsKeeper = accountsKeeper
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.BankKeeper = bankkeeper.NewBaseKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger),
@ -315,6 +314,10 @@ func NewSimApp(
txConfigOpts := authtx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper),
SigningOptions: &signing.Options{
AddressCodec: signingCtx.AddressCodec(),
ValidatorAddressCodec: signingCtx.ValidatorAddressCodec(),
},
}
txConfig, err = authtx.NewTxConfigWithOptions(
appCodec,
@ -326,7 +329,7 @@ func NewSimApp(
app.txConfig = txConfig
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), signingCtx.ValidatorAddressCodec(), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
)
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())

View File

@ -14,6 +14,7 @@ import (
"cosmossdk.io/x/auth/tx"
authtxconfig "cosmossdk.io/x/auth/tx/config"
"cosmossdk.io/x/auth/types"
txsigning "cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
@ -49,7 +50,9 @@ func NewRootCmd() *cobra.Command {
WithValidatorAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix())).
WithConsensusAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix())).
WithHomeDir(simapp.DefaultNodeHome).
WithViper("") // uses by default the binary name as prefix
WithViper(""). // uses by default the binary name as prefix
WithAddressPrefix(sdk.GetConfig().GetBech32AccountAddrPrefix()).
WithValidatorPrefix(sdk.GetConfig().GetBech32ValidatorAddrPrefix())
rootCmd := &cobra.Command{
Use: "simd",
@ -80,6 +83,10 @@ func NewRootCmd() *cobra.Command {
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
SigningOptions: &txsigning.Options{
AddressCodec: initClientCtx.InterfaceRegistry.SigningContext().AddressCodec(),
ValidatorAddressCodec: initClientCtx.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
},
}
txConfig, err := tx.NewTxConfigWithOptions(
initClientCtx.Codec,

View File

@ -7,6 +7,8 @@ import (
"github.com/spf13/cobra"
authv1 "cosmossdk.io/api/cosmos/auth/module/v1"
stakingv1 "cosmossdk.io/api/cosmos/staking/module/v1"
"cosmossdk.io/client/v2/autocli"
clientv2keyring "cosmossdk.io/client/v2/autocli/keyring"
"cosmossdk.io/core/address"
@ -103,6 +105,8 @@ func ProvideClientContext(
addressCodec address.Codec,
validatorAddressCodec runtime.ValidatorAddressCodec,
consensusAddressCodec runtime.ConsensusAddressCodec,
authConfig *authv1.Module,
stakingConfig *stakingv1.Module,
) client.Context {
var err error
@ -116,7 +120,9 @@ func ProvideClientContext(
WithValidatorAddressCodec(validatorAddressCodec).
WithConsensusAddressCodec(consensusAddressCodec).
WithHomeDir(simapp.DefaultNodeHome).
WithViper("") // uses by default the binary name as prefix
WithViper(""). // uses by default the binary name as prefix
WithAddressPrefix(authConfig.Bech32Prefix).
WithValidatorPrefix(stakingConfig.Bech32PrefixValidator)
// Read the config to overwrite the default values with the values from the config file
customClientTemplate, customClientConfig := initClientConfig()

View File

@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
"github.com/cosmos/cosmos-sdk/types/module"
@ -46,7 +47,7 @@ func Test_TestnetCmd(t *testing.T) {
require.Len(t, moduleManager.Modules, 7)
home := t.TempDir()
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, staking.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, staking.AppModule{})
logger := log.NewNopLogger()
cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)

View File

@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
@ -56,7 +57,7 @@ func TestCLITestSuite(t *testing.T) {
}
func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, gov.AppModule{})
s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.
WithKeyring(s.kr).

View File

@ -26,6 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
cdctestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
@ -175,7 +176,7 @@ func TestSendNotEnoughBalance(t *testing.T) {
require.NoError(t, err)
sendMsg := types.NewMsgSend(addr1Str, addr2Str, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)})
header := header.Info{Height: baseApp.LastBlockHeight() + 1}
txConfig := moduletestutil.MakeTestTxConfig()
txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{})
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
require.Error(t, err)
@ -255,7 +256,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
header := header.Info{Height: baseApp.LastBlockHeight() + 1}
txConfig := moduletestutil.MakeTestTxConfig()
txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{})
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
if tc.expPass {
require.NoError(t, err)
@ -308,7 +309,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) {
for _, tc := range testCases {
header := header.Info{Height: baseApp.LastBlockHeight() + 1}
txConfig := moduletestutil.MakeTestTxConfig()
txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{})
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
require.NoError(t, err)
@ -363,7 +364,7 @@ func TestMsgMultiSendDependent(t *testing.T) {
for _, tc := range testCases {
header := header.Info{Height: baseApp.LastBlockHeight() + 1}
txConfig := moduletestutil.MakeTestTxConfig()
txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{})
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
require.NoError(t, err)

View File

@ -15,6 +15,7 @@ import (
stakingtypes "cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -82,7 +83,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) {
_, err = baseApp.Commit()
require.NoError(b, err)
txGen := moduletestutil.MakeTestTxConfig()
txGen := moduletestutil.MakeTestTxConfig(codectestutil.CodecOptions{})
txEncoder := txGen.TxEncoder()
// pre-compute all txs
@ -140,7 +141,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) {
_, err = baseApp.Commit()
require.NoError(b, err)
txGen := moduletestutil.MakeTestTxConfig()
txGen := moduletestutil.MakeTestTxConfig(codectestutil.CodecOptions{})
txEncoder := txGen.TxEncoder()
// pre-compute all txs

View File

@ -23,6 +23,7 @@ import (
_ "cosmossdk.io/x/staking"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
@ -63,7 +64,8 @@ type deterministicFixture struct {
func initDeterministicFixture(t *testing.T) *deterministicFixture {
t.Helper()
keys := storetypes.NewKVStoreKeys(authtypes.StoreKey, banktypes.StoreKey)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(t)
cms := integration.CreateMultiStore(keys, logger)
@ -101,10 +103,13 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
@ -38,7 +39,7 @@ func TestCLITestSuite(t *testing.T) {
}
func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig()
s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.
WithKeyring(s.kr).

View File

@ -33,6 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -66,7 +67,8 @@ func initFixture(t *testing.T) *fixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, distrtypes.StoreKey, pooltypes.StoreKey, stakingtypes.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, distribution.AppModule{}, protocolpool.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(t)
cms := integration.CreateMultiStore(keys, logger)
@ -138,13 +140,16 @@ func initFixture(t *testing.T) *fixture {
},
})
integrationApp := integration.NewIntegrationApp(ctx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
})
integrationApp := integration.NewIntegrationApp(ctx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -41,6 +41,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
@ -87,7 +88,8 @@ func initFixture(tb testing.TB) *fixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, consensusparamtypes.StoreKey, evidencetypes.StoreKey, stakingtypes.StoreKey, slashingtypes.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, evidence.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, evidence.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(tb)
cms := integration.CreateMultiStore(keys, logger)
@ -141,13 +143,16 @@ func initFixture(tb testing.TB) *fixture {
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry())
evidenceModule := evidence.NewAppModule(*evidenceKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -18,6 +18,7 @@ import (
minttypes "cosmossdk.io/x/mint/types"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -29,7 +30,9 @@ import (
func Example() {
// in this example we are testing the integration of the following modules:
// - mint, which directly depends on auth, bank and staking
encodingCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, mint.AppModule{})
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, mint.AppModule{})
signingCtx := encodingCfg.InterfaceRegistry.SigningContext()
keys := storetypes.NewKVStoreKeys(authtypes.StoreKey, minttypes.StoreKey)
authority := authtypes.NewModuleAddress("gov").String()
@ -63,6 +66,8 @@ func Example() {
logger,
keys,
encodingCfg.Codec,
signingCtx.AddressCodec(),
signingCtx.ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
minttypes.ModuleName: mintModule,
@ -118,7 +123,7 @@ func Example() {
// That module has no dependency on other modules.
func Example_oneModule() {
// in this example we are testing the integration of the auth module:
encodingCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
keys := storetypes.NewKVStoreKeys(authtypes.StoreKey)
authority := authtypes.NewModuleAddress("gov").String()
@ -147,6 +152,8 @@ func Example_oneModule() {
logger,
keys,
encodingCfg.Codec,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
},

View File

@ -29,6 +29,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -52,7 +53,8 @@ func initFixture(tb testing.TB) *fixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, gov.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(tb)
cms := integration.CreateMultiStore(keys, logger)
@ -128,12 +130,15 @@ func initFixture(tb testing.TB) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
govModule := gov.NewAppModule(cdc, govKeeper, accountKeeper, bankKeeper, poolKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -30,6 +30,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -56,7 +57,8 @@ func initFixture(tb testing.TB) *fixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, slashingtypes.StoreKey, stakingtypes.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(tb)
cms := integration.CreateMultiStore(keys, logger)
@ -100,11 +102,14 @@ func initFixture(tb testing.TB) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry())
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -26,6 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -103,7 +104,8 @@ func initFixture(tb testing.TB) *fixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, types.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, staking.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, staking.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(tb)
cms := integration.CreateMultiStore(keys, logger)
@ -147,11 +149,14 @@ func initFixture(tb testing.TB) *fixture {
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

View File

@ -27,6 +27,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/runtime"
@ -68,7 +69,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, distribution.AppModule{}).Codec
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, distribution.AppModule{})
cdc := encodingCfg.Codec
logger := log.NewTestLogger(t)
cms := integration.CreateMultiStore(keys, logger)
@ -111,11 +113,14 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
})
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
})
ctx := integrationApp.Context()

View File

@ -61,6 +61,7 @@ import (
signing_testutil "cosmossdk.io/x/tx/signing/testutil"
"cosmossdk.io/x/upgrade"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
ed25519types "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
@ -92,8 +93,8 @@ import (
// by the mutation of genOpts passed to the generator.
func TestAminoJSON_Equivalence(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(
auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, consensus.AppModule{},
distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{},
codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{},
consensus.AppModule{}, distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{},
gov.AppModule{}, groupmodule.AppModule{}, mint.AppModule{},
slashing.AppModule{}, staking.AppModule{}, upgrade.AppModule{}, vesting.AppModule{})
legacytx.RegressionTestingAminoCodec = encCfg.Amino
@ -208,7 +209,7 @@ func newAny(t *testing.T, msg proto.Message) *anypb.Any {
// TestAminoJSON_LegacyParity tests that the Encoder encoder produces the same output as the Encoder encoder.
func TestAminoJSON_LegacyParity(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(auth.AppModule{}, authzmodule.AppModule{},
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{},
bank.AppModule{}, distribution.AppModule{}, slashing.AppModule{}, staking.AppModule{},
vesting.AppModule{}, gov.AppModule{})
legacytx.RegressionTestingAminoCodec = encCfg.Amino
@ -512,7 +513,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
}
func TestSendAuthorization(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(auth.AppModule{}, authzmodule.AppModule{},
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{},
distribution.AppModule{}, bank.AppModule{})
aj := aminojson.NewEncoder(aminojson.EncoderOptions{})
@ -562,7 +563,7 @@ func TestSendAuthorization(t *testing.T) {
}
func TestDecimalMutation(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(staking.AppModule{})
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{})
rates := &stakingtypes.CommissionRates{}
rateBz, _ := encCfg.Amino.MarshalJSON(rates)
require.Equal(t, `{"rate":"0","max_rate":"0","max_change_rate":"0"}`, string(rateBz))

View File

@ -30,6 +30,7 @@ import (
"cosmossdk.io/x/upgrade"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/tests/integration/rapidgen"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
@ -43,8 +44,8 @@ import (
// TestDecode tests that the tx decoder can decode all the txs in the test suite.
func TestDecode(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(
auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, consensus.AppModule{},
distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{},
codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{},
consensus.AppModule{}, distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{},
gov.AppModule{}, groupmodule.AppModule{}, mint.AppModule{},
slashing.AppModule{}, staking.AppModule{}, upgrade.AppModule{}, vesting.AppModule{})
legacytx.RegressionTestingAminoCodec = encCfg.Amino

View File

@ -8,6 +8,7 @@ import (
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
"cosmossdk.io/store"
@ -46,6 +47,8 @@ func NewIntegrationApp(
logger log.Logger,
keys map[string]*storetypes.KVStoreKey,
appCodec codec.Codec,
addressCodec address.Codec,
validatorCodec address.Codec,
modules map[string]appmodule.AppModule,
) *App {
db := dbm.NewMemDB()
@ -54,7 +57,7 @@ func NewIntegrationApp(
moduleManager := module.NewManagerFromMap(modules)
moduleManager.RegisterInterfaces(interfaceRegistry)
txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), authtx.DefaultSignModes)
txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), addressCodec, validatorCodec, authtx.DefaultSignModes)
bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName))
bApp.MountKVStores(keys)

View File

@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/require"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/types"
@ -13,7 +14,7 @@ import (
func TestGenerateCoinKey(t *testing.T) {
t.Parallel()
cdc := testutil.MakeTestEncodingConfig().Codec
cdc := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec
addr, mnemonic, err := GenerateCoinKey(hd.Secp256k1, cdc)
require.NoError(t, err)
@ -28,7 +29,7 @@ func TestGenerateCoinKey(t *testing.T) {
func TestGenerateSaveCoinKey(t *testing.T) {
t.Parallel()
encCfg := testutil.MakeTestEncodingConfig()
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil, encCfg.Codec)
require.NoError(t, err)
@ -53,7 +54,7 @@ func TestGenerateSaveCoinKey(t *testing.T) {
func TestGenerateSaveCoinKeyOverwriteFlag(t *testing.T) {
t.Parallel()
encCfg := testutil.MakeTestEncodingConfig()
encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil, encCfg.Codec)
require.NoError(t, err)

View File

@ -52,10 +52,11 @@ func SetupSimulation(config simtypes.Config, dirPrefix, dbName string, verbose,
// SimulationOperations retrieves the simulation params from the provided file path
// and returns all the modules weighted operations
func SimulationOperations(app runtime.AppSimI, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation {
signingCtx := cdc.InterfaceRegistry().SigningContext()
simState := module.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: cdc,
TxConfig: authtx.NewTxConfig(cdc, authtx.DefaultSignModes), // TODO(tip): we should extract this from app
TxConfig: authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), // TODO(tip): we should extract this from app
BondDenom: sdk.DefaultBondDenom,
}

View File

@ -71,6 +71,31 @@ const (
Bech32PrefixConsPub = Bech32MainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic
)
// GetBech32PrefixAccPub returns the Bech32 prefix of an account's public key.
func GetBech32PrefixAccPub(mainPrefix string) string {
return mainPrefix + PrefixPublic
}
// GetBech32PrefixValAddr returns the Bech32 prefix of a validator's operator address.
func GetBech32PrefixValAddr(mainPrefix string) string {
return mainPrefix + PrefixValidator + PrefixOperator
}
// GetBech32PrefixValPub returns the Bech32 prefix of a validator's operator public key.
func GetBech32PrefixValPub(mainPrefix string) string {
return mainPrefix + PrefixValidator + PrefixOperator + PrefixPublic
}
// GetBech32PrefixConsAddr returns the Bech32 prefix of a consensus node address.
func GetBech32PrefixConsAddr(mainPrefix string) string {
return mainPrefix + PrefixValidator + PrefixConsensus
}
// GetBech32PrefixConsPub returns the Bech32 prefix of a consensus node public key.
func GetBech32PrefixConsPub(mainPrefix string) string {
return mainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic
}
// cache variables
var (
// AccAddress.String() is expensive and if unoptimized dominantly showed up in profiles,

View File

@ -13,7 +13,6 @@ const DefaultKeyringServiceName = "cosmos"
// Config is the structure that holds the SDK configuration parameters.
// This could be used to initialize certain configuration parameters for the SDK.
type Config struct {
fullFundraiserPath string
bech32AddressPrefix map[string]string
mtx sync.RWMutex
@ -39,7 +38,6 @@ func NewConfig() *Config {
"validator_pub": Bech32PrefixValPub,
"consensus_pub": Bech32PrefixConsPub,
},
fullFundraiserPath: FullFundraiserPath,
}
}
@ -96,14 +94,6 @@ func (config *Config) SetBech32PrefixForConsensusNode(addressPrefix, pubKeyPrefi
config.bech32AddressPrefix["consensus_pub"] = pubKeyPrefix
}
// Set the FullFundraiserPath (BIP44Prefix) on the config.
//
// Deprecated: This method is supported for backward compatibility only and will be removed in a future release. Use SetPurpose and SetCoinType instead.
func (config *Config) SetFullFundraiserPath(fullFundraiserPath string) {
config.assertNotSealed()
config.fullFundraiserPath = fullFundraiserPath
}
// Seal seals the config such that the config state could not be modified further
func (config *Config) Seal() *Config {
config.mtx.Lock()

View File

@ -14,6 +14,7 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/x/auth/signing"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"
@ -236,7 +237,7 @@ func (s *MempoolTestSuite) TestSampleTxs() {
}
func unmarshalTx(txBytes []byte) (sdk.Tx, error) {
cfg := moduletestutil.MakeTestEncodingConfig(counter.AppModule{})
cfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, counter.AppModule{})
return cfg.TxConfig.TxJSONDecoder()(txBytes)
}

View File

@ -22,15 +22,16 @@ type TestEncodingConfig struct {
Amino *codec.LegacyAmino
}
func MakeTestEncodingConfig(modules ...module.AppModule) TestEncodingConfig {
func MakeTestEncodingConfig(codecOpt testutil.CodecOptions, modules ...module.AppModule) TestEncodingConfig {
aminoCodec := codec.NewLegacyAmino()
interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry()
codec := codec.NewProtoCodec(interfaceRegistry)
interfaceRegistry := codecOpt.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
signingCtx := cdc.InterfaceRegistry().SigningContext()
encCfg := TestEncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: codec,
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
Codec: cdc,
TxConfig: tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes),
Amino: aminoCodec,
}
@ -43,10 +44,11 @@ func MakeTestEncodingConfig(modules ...module.AppModule) TestEncodingConfig {
return encCfg
}
func MakeTestTxConfig() client.TxConfig {
interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry()
func MakeTestTxConfig(codecOpt testutil.CodecOptions) client.TxConfig {
interfaceRegistry := codecOpt.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
return tx.NewTxConfig(cdc, tx.DefaultSignModes)
signingCtx := interfaceRegistry.SigningContext()
return tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes)
}
type TestBuilderTxConfig struct {
@ -54,9 +56,9 @@ type TestBuilderTxConfig struct {
TxBuilder *TestTxBuilder
}
func MakeBuilderTestTxConfig() TestBuilderTxConfig {
func MakeBuilderTestTxConfig(codecOpt testutil.CodecOptions) TestBuilderTxConfig {
return TestBuilderTxConfig{
TxConfig: MakeTestTxConfig(),
TxConfig: MakeTestTxConfig(codecOpt),
}
}

View File

@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes
* [#19447](https://github.com/cosmos/cosmos-sdk/pull/19447) Address and validator address codecs are now arguments of `NewTxConfig`. `NewDefaultSigningOptions` has been replaced with `NewSigningOptions` which takes address and validator address codecs as arguments.
* [#17985](https://github.com/cosmos/cosmos-sdk/pull/17985) Remove `StdTxConfig`
* [#19161](https://github.com/cosmos/cosmos-sdk/pull/19161) Remove `simulate` from `SetGasMeter`
* [#19363](https://github.com/cosmos/cosmos-sdk/pull/19363) Remove `IterateAccounts` and `GetAllAccounts` methods from the AccountKeeper interface and Keeper.

View File

@ -145,7 +145,9 @@ func TestDeductFeesNoDelegation(t *testing.T) {
tc := stc // to make scopelint happy
t.Run(name, func(t *testing.T) {
suite := SetupTestSuite(t, false)
protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), tx.DefaultSignModes)
cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry)
signingCtx := suite.encCfg.InterfaceRegistry.SigningContext()
protoTxCfg := tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes)
// this just tests our handler
dfd := ante.NewDeductFeeDecorator(suite.accountKeeper, suite.bankKeeper, suite.feeGrantKeeper, nil)
feeAnteHandler := sdk.ChainAnteDecorators(dfd)

View File

@ -15,6 +15,7 @@ import (
authtx "cosmossdk.io/x/auth/tx"
txmodule "cosmossdk.io/x/auth/tx/config"
"cosmossdk.io/x/auth/types"
txsigning "cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@ -99,13 +100,18 @@ func TestSigVerification(t *testing.T) {
enabledSignModes := []signing.SignMode{signing.SignMode_SIGN_MODE_DIRECT, signing.SignMode_SIGN_MODE_TEXTUAL, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON}
// Since TEXTUAL is not enabled by default, we create a custom TxConfig
// here which includes it.
cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry)
txConfigOpts := authtx.ConfigOptions{
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(suite.clientCtx),
EnabledSignModes: enabledSignModes,
SigningOptions: &txsigning.Options{
AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(),
ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(),
},
}
var err error
suite.clientCtx.TxConfig, err = authtx.NewTxConfigWithOptions(
codec.NewProtoCodec(suite.encCfg.InterfaceRegistry),
cdc,
txConfigOpts,
)
require.NoError(t, err)
@ -138,6 +144,10 @@ func TestSigVerification(t *testing.T) {
txConfigOpts = authtx.ConfigOptions{
TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(suite.txBankKeeper),
EnabledSignModes: enabledSignModes,
SigningOptions: &txsigning.Options{
AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(),
ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(),
},
}
anteTxConfig, err := authtx.NewTxConfigWithOptions(
codec.NewProtoCodec(suite.encCfg.InterfaceRegistry),
@ -303,13 +313,18 @@ func TestAnteHandlerChecks(t *testing.T) {
enabledSignModes := []signing.SignMode{signing.SignMode_SIGN_MODE_DIRECT, signing.SignMode_SIGN_MODE_TEXTUAL, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON}
// Since TEXTUAL is not enabled by default, we create a custom TxConfig
// here which includes it.
cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry)
txConfigOpts := authtx.ConfigOptions{
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(suite.clientCtx),
EnabledSignModes: enabledSignModes,
SigningOptions: &txsigning.Options{
AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(),
ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(),
},
}
anteTxConfig, err := authtx.NewTxConfigWithOptions(
codec.NewProtoCodec(suite.encCfg.InterfaceRegistry),
cdc,
txConfigOpts,
)
require.NoError(t, err)

View File

@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -67,7 +68,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1)
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
maccPerms := map[string][]string{
"fee_collector": nil,

View File

@ -11,13 +11,14 @@ import (
"cosmossdk.io/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/client"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)
func TestGetCommandEncode(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
txConfig := encodingConfig.TxConfig
cdc := encodingConfig.Codec
@ -47,7 +48,7 @@ func TestGetCommandEncode(t *testing.T) {
}
func TestGetCommandDecode(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
txConfig := encodingConfig.TxConfig
cdc := encodingConfig.Codec

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -38,7 +39,7 @@ func TestParseQueryResponse(t *testing.T) {
func TestReadTxFromFile(t *testing.T) {
t.Parallel()
encodingConfig := moduletestutil.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig
@ -74,7 +75,7 @@ func TestReadTxFromFile(t *testing.T) {
func TestReadTxsFromFile(t *testing.T) {
t.Parallel()
encodingConfig := moduletestutil.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig
@ -138,7 +139,7 @@ func TestReadTxsFromFile(t *testing.T) {
func TestBatchScanner_Scan(t *testing.T) {
t.Parallel()
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
txConfig := encodingConfig.TxConfig
clientCtx := client.Context{}

View File

@ -19,6 +19,7 @@ import (
"cosmossdk.io/x/auth/types"
"github.com/cosmos/cosmos-sdk/baseapp"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -52,7 +53,7 @@ func TestDeterministicTestSuite(t *testing.T) {
}
func (suite *DeterministicTestSuite) SetupTest() {
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
suite.Require()
key := storetypes.NewKVStoreKey(types.StoreKey)

View File

@ -15,6 +15,7 @@ import (
"cosmossdk.io/x/auth/types"
"github.com/cosmos/cosmos-sdk/baseapp"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/runtime"
@ -46,7 +47,7 @@ type KeeperTestSuite struct {
}
func (suite *KeeperTestSuite) SetupTest() {
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)

View File

@ -8,13 +8,14 @@ import (
authsign "cosmossdk.io/x/auth/signing"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
)
func TestGetSignBytesAdapterNoPublicKey(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
txConfig := encodingConfig.TxConfig
_, _, addr := testdata.KeyTestPubAddr()
signerData := authsign.SignerData{

View File

@ -9,6 +9,7 @@ import (
authsigning "cosmossdk.io/x/auth/signing"
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
_ "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
@ -39,7 +40,7 @@ var (
// client.TxBuilder created by the fee payer.
func TestBuilderWithAux(t *testing.T) {
t.Skip("restore when we re-enable aux on the TX builder")
encodingConfig := moduletestutil.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig

View File

@ -1,10 +1,10 @@
package tx
import (
"errors"
"fmt"
"cosmossdk.io/core/address"
authcodec "cosmossdk.io/x/auth/codec"
txdecode "cosmossdk.io/x/tx/decode"
txsigning "cosmossdk.io/x/tx/signing"
"cosmossdk.io/x/tx/signing/aminojson"
@ -76,12 +76,15 @@ var DefaultSignModes = []signingtypes.SignMode{
// We prefer to use depinject to provide client.TxConfig, but we permit this constructor usage. Within the SDK,
// this constructor is primarily used in tests, but also sees usage in app chains like:
// https://github.com/evmos/evmos/blob/719363fbb92ff3ea9649694bd088e4c6fe9c195f/encoding/config.go#L37
func NewTxConfig(protoCodec codec.Codec, enabledSignModes []signingtypes.SignMode,
customSignModes ...txsigning.SignModeHandler,
func NewTxConfig(protoCodec codec.Codec, addressCodec, validatorAddressCodec address.Codec, enabledSignModes []signingtypes.SignMode, customSignModes ...txsigning.SignModeHandler,
) client.TxConfig {
txConfig, err := NewTxConfigWithOptions(protoCodec, ConfigOptions{
EnabledSignModes: enabledSignModes,
CustomSignModes: customSignModes,
SigningOptions: &txsigning.Options{
AddressCodec: addressCodec,
ValidatorAddressCodec: validatorAddressCodec,
},
})
if err != nil {
panic(err)
@ -89,13 +92,12 @@ func NewTxConfig(protoCodec codec.Codec, enabledSignModes []signingtypes.SignMod
return txConfig
}
// NewDefaultSigningOptions returns the sdk default signing options used by x/tx. This includes account and
// NewSigningOptions returns signing options used by x/tx. This includes account and
// validator address prefix enabled codecs.
func NewDefaultSigningOptions() (*txsigning.Options, error) {
sdkConfig := sdk.GetConfig()
func NewSigningOptions(addressCodec, validatorAddressCodec address.Codec) (*txsigning.Options, error) {
return &txsigning.Options{
AddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32AccountAddrPrefix()),
ValidatorAddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32ValidatorAddrPrefix()),
AddressCodec: addressCodec,
ValidatorAddressCodec: validatorAddressCodec,
}, nil
}
@ -105,10 +107,7 @@ func NewDefaultSigningOptions() (*txsigning.Options, error) {
func NewSigningHandlerMap(configOpts ConfigOptions) (*txsigning.HandlerMap, error) {
var err error
if configOpts.SigningOptions == nil {
configOpts.SigningOptions, err = NewDefaultSigningOptions()
if err != nil {
return nil, err
}
return nil, errors.New("signing options not provided")
}
if configOpts.SigningContext == nil {
configOpts.SigningContext, err = txsigning.NewContext(*configOpts.SigningOptions)
@ -179,10 +178,7 @@ func NewTxConfigWithOptions(protoCodec codec.Codec, configOptions ConfigOptions)
var err error
if configOptions.SigningContext == nil {
if configOptions.SigningOptions == nil {
configOptions.SigningOptions, err = NewDefaultSigningOptions()
if err != nil {
return nil, err
}
return nil, errors.New("signing options not provided")
}
if configOptions.SigningOptions.FileResolver == nil {
configOptions.SigningOptions.FileResolver = protoCodec.InterfaceRegistry()

View File

@ -9,10 +9,10 @@ import (
_ "cosmossdk.io/api/cosmos/crypto/secp256k1"
"cosmossdk.io/x/auth/tx"
txtestutil "cosmossdk.io/x/auth/tx/testutil"
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -23,13 +23,17 @@ func TestGenerator(t *testing.T) {
std.RegisterInterfaces(interfaceRegistry)
interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{})
protoCodec := codec.NewProtoCodec(interfaceRegistry)
suite.Run(t, txtestutil.NewTxConfigTestSuite(tx.NewTxConfig(protoCodec, tx.DefaultSignModes)))
signingCtx := protoCodec.InterfaceRegistry().SigningContext()
suite.Run(t, txtestutil.NewTxConfigTestSuite(tx.NewTxConfig(protoCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes)))
}
func TestConfigOptions(t *testing.T) {
interfaceRegistry := types.NewInterfaceRegistry()
interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry()
protoCodec := codec.NewProtoCodec(interfaceRegistry)
configOptions := tx.ConfigOptions{}
configOptions := tx.ConfigOptions{SigningOptions: &signing.Options{
AddressCodec: interfaceRegistry.SigningContext().AddressCodec(),
ValidatorAddressCodec: interfaceRegistry.SigningContext().ValidatorAddressCodec(),
}}
txConfig, err := tx.NewTxConfigWithOptions(protoCodec, configOptions)
require.NoError(t, err)
require.NotNil(t, txConfig)

View File

@ -10,6 +10,7 @@ import (
"cosmossdk.io/x/auth"
"cosmossdk.io/x/auth/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -54,7 +55,7 @@ func TestValidateGenesisDuplicateAccounts(t *testing.T) {
}
func TestGenesisAccountIterator(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
cdc := encodingConfig.Codec
acc1 := types.NewBaseAccountWithAddress(sdk.AccAddress(addr1))

View File

@ -16,6 +16,7 @@ import (
"cosmossdk.io/x/auth/vesting"
"cosmossdk.io/x/auth/vesting/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -38,7 +39,7 @@ type VestingAccountTestSuite struct {
}
func (s *VestingAccountTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, vesting.AppModule{})
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())

View File

@ -23,6 +23,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -51,7 +52,7 @@ func TestCLITestSuite(t *testing.T) {
}
func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig(bank.AppModule{}, authz.AppModule{})
s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, bank.AppModule{}, authz.AppModule{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.

View File

@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -48,7 +49,7 @@ func (suite *GenesisTestSuite) SetupTest() {
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{})
// gomock initializations
ctrl := gomock.NewController(suite.T())

View File

@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -51,7 +52,7 @@ func (s *TestSuite) SetupTest() {
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now().Round(0).UTC()})
s.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{})
s.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{})
s.baseApp = baseapp.NewBaseApp(
"authz",

View File

@ -16,6 +16,7 @@ import (
"cosmossdk.io/x/bank"
banktypes "cosmossdk.io/x/bank/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/runtime"
@ -25,7 +26,7 @@ import (
)
func TestMigration(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}, bank.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}, bank.AppModule{})
cdc := encodingConfig.Codec
authzKey := storetypes.NewKVStoreKey("authz")

View File

@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -30,7 +31,7 @@ func TestExpiredGrantsQueue(t *testing.T) {
key := storetypes.NewKVStoreKey(keeper.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{})
ctx := testCtx.Ctx
baseApp := baseapp.NewBaseApp(

View File

@ -13,13 +13,14 @@ import (
"cosmossdk.io/x/authz/simulation"
banktypes "cosmossdk.io/x/bank/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)
func TestDecodeStore(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{})
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)
dec := simulation.NewDecodeStore(encCfg.Codec)

View File

@ -13,13 +13,14 @@ import (
"cosmossdk.io/x/authz/simulation"
banktypes "cosmossdk.io/x/bank/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/types/module"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
func TestRandomizedGenState(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{})
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)
s := rand.NewSource(1)

View File

@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/testutil"
@ -37,7 +38,7 @@ func TestCLITestSuite(t *testing.T) {
}
func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig(bank.AppModule{})
s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, bank.AppModule{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.
WithKeyring(s.kr).

View File

@ -18,6 +18,7 @@ import (
banktypes "cosmossdk.io/x/bank/types"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -28,7 +29,7 @@ func TestBankStateCompatibility(t *testing.T) {
key := storetypes.NewKVStoreKey(banktypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())

View File

@ -27,6 +27,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -129,7 +130,7 @@ func (suite *KeeperTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(banktypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
@ -303,7 +304,7 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
NewKeeperWithAuthority := func(authority string) keeper.BaseKeeper {
return keeper.NewBaseKeeper(
env,
moduletestutil.MakeTestEncodingConfig().Codec,
moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec,
suite.authKeeper,
nil,
authority,

View File

@ -12,6 +12,7 @@ import (
cbtypes "cosmossdk.io/x/circuit/types"
"github.com/cosmos/cosmos-sdk/client"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -37,7 +38,7 @@ func (m MockCircuitBreaker) IsAllowed(ctx context.Context, typeURL string) (bool
func initFixture(t *testing.T) *fixture {
t.Helper()
mockStoreKey := storetypes.NewKVStoreKey("test")
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
mockclientCtx := client.Context{}.
WithTxConfig(encCfg.TxConfig)

View File

@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -37,7 +38,7 @@ func TestGenesisTestSuite(t *testing.T) {
func (s *GenesisTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(types.ModuleName)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(circuit.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, circuit.AppModule{})
sdkCtx := testCtx.Ctx
s.ctx = sdkCtx

View File

@ -16,6 +16,7 @@ import (
"cosmossdk.io/x/circuit/types"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -40,7 +41,7 @@ type fixture struct {
func initFixture(t *testing.T) *fixture {
t.Helper()
encCfg := moduletestutil.MakeTestEncodingConfig(circuit.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, circuit.AppModule{})
ac := addresscodec.NewBech32Codec("cosmos")
mockStoreKey := storetypes.NewKVStoreKey("test")

View File

@ -12,6 +12,7 @@ import (
authtypes "cosmossdk.io/x/auth/types"
"github.com/cosmos/cosmos-sdk/baseapp"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -32,7 +33,7 @@ func (s *KeeperTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(consensusparamkeeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx
encCfg := moduletestutil.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
keeper := consensusparamkeeper.NewKeeper(encCfg.Codec, env, authtypes.NewModuleAddress("gov").String())

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -37,7 +38,7 @@ func (s *GenesisTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
// gomock initializations
ctrl := gomock.NewController(s.T())

View File

@ -9,6 +9,7 @@ import (
storetypes "cosmossdk.io/store/types"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -26,7 +27,7 @@ func TestLogger(t *testing.T) {
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos"))
require.Equal(t,
@ -40,7 +41,7 @@ func TestInvariants(t *testing.T) {
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos"))
require.Equal(t, keeper.InvCheckPeriod(), uint(5))
@ -57,7 +58,7 @@ func TestAssertInvariants(t *testing.T) {
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos"))
keeper.RegisterRoute("testModule", "testRoute1", func(sdk.Context) (string, bool) { return "", false })

View File

@ -10,6 +10,7 @@ import (
storetypes "cosmossdk.io/store/types"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -37,7 +38,7 @@ func (s *KeeperTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", sdk.AccAddress([]byte("addr1_______________")).String(), addresscodec.NewBech32Codec("cosmos"))
s.ctx = testCtx.Ctx
@ -51,7 +52,7 @@ func (s *KeeperTestSuite) TestMsgVerifyInvariant() {
err := s.keeper.ConstantFee.Set(s.ctx, constantFee)
s.Require().NoError(err)
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
kr := keyring.NewInMemory(encCfg.Codec)
testutil.CreateKeyringAccounts(s.T(), kr, 1)

View File

@ -21,6 +21,7 @@ import (
stakingtypes "cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -31,7 +32,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -91,7 +92,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -223,7 +224,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)

View File

@ -19,6 +19,7 @@ import (
stakingtypes "cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -29,7 +30,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -132,7 +133,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -238,7 +239,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -365,7 +366,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -465,7 +466,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -543,7 +544,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -662,7 +663,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -804,7 +805,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
@ -1006,7 +1007,7 @@ func Test100PercentCommissionReward(t *testing.T) {
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)

View File

@ -18,6 +18,7 @@ import (
"cosmossdk.io/x/distribution/types"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -38,7 +39,7 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de
ctrl := gomock.NewController(t)
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
addrs := simtestutil.CreateIncrementalAccounts(2)

View File

@ -22,6 +22,7 @@ import (
pooltypes "cosmossdk.io/x/protocolpool/types"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -34,7 +35,7 @@ func TestFundsMigration(t *testing.T) {
)
logger := log.NewTestLogger(t)
cms := integration.CreateMultiStore(keys, logger)
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, distribution.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, distribution.AppModule{})
ctx := sdk.NewContext(cms, true, logger)
maccPerms := map[string][]string{

View File

@ -12,6 +12,7 @@ import (
"cosmossdk.io/x/distribution"
v4 "cosmossdk.io/x/distribution/migrations/v4"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -20,7 +21,7 @@ import (
)
func TestMigration(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}).Codec
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec
storeKey := storetypes.NewKVStoreKey("distribution")
storeService := runtime.NewKVStoreService(storeKey)
tKey := storetypes.NewTransientStoreKey("transient_test")

View File

@ -11,6 +11,7 @@ import (
"cosmossdk.io/x/distribution/simulation"
"cosmossdk.io/x/distribution/types"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
@ -24,7 +25,7 @@ var (
)
func TestDecodeDistributionStore(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
cdc := encodingConfig.Codec
dec := simulation.NewDecodeStore(cdc)

View File

@ -21,6 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
@ -84,7 +85,7 @@ type KeeperTestSuite struct {
}
func (suite *KeeperTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(evidence.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, evidence.AppModule{})
key := storetypes.NewKVStoreKey(types.StoreKey)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
tkey := storetypes.NewTransientStoreKey("evidence_transient_store")
@ -115,7 +116,7 @@ func (suite *KeeperTestSuite) SetupTest() {
evidenceKeeper.SetRouter(router)
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(evidence.AppModule{})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, evidence.AppModule{})
suite.accountKeeper = accountKeeper

View File

@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
@ -61,7 +62,7 @@ func TestCLITestSuite(t *testing.T) {
func (s *CLITestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
s.encCfg = testutilmod.MakeTestEncodingConfig(module.AppModule{}, gov.AppModule{})
s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}, gov.AppModule{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.
WithKeyring(s.kr).

View File

@ -14,6 +14,7 @@ import (
"cosmossdk.io/x/feegrant/module"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -22,7 +23,7 @@ import (
func TestFilteredFeeValidAllow(t *testing.T) {
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})

View File

@ -12,6 +12,7 @@ import (
"cosmossdk.io/x/feegrant/module"
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -21,7 +22,7 @@ func TestGrant(t *testing.T) {
addressCodec := codecaddress.NewBech32Codec("cosmos")
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})

View File

@ -17,6 +17,7 @@ import (
feegranttestutil "cosmossdk.io/x/feegrant/testutil"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
@ -43,7 +44,7 @@ func initFixture(t *testing.T) *genesisFixture {
t.Helper()
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
ctrl := gomock.NewController(t)
accountKeeper := feegranttestutil.NewMockAccountKeeper(ctrl)

View File

@ -17,6 +17,7 @@ import (
feegranttestutil "cosmossdk.io/x/feegrant/testutil"
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -44,7 +45,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.addrs = simtestutil.CreateIncrementalAccounts(20)
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
// setup gomock and initialize some globally expected executions
ctrl := gomock.NewController(suite.T())

View File

@ -15,6 +15,7 @@ import (
"cosmossdk.io/x/feegrant/module"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@ -23,7 +24,7 @@ import (
)
func TestMigration(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
cdc := encodingConfig.Codec
ac := addresscodec.NewBech32Codec("cosmos")

View File

@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -28,7 +29,7 @@ import (
func TestFeegrantPruning(t *testing.T) {
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
addrs := simtestutil.CreateIncrementalAccounts(4)
granter1 := addrs[0]

View File

@ -12,6 +12,7 @@ import (
"cosmossdk.io/x/feegrant/simulation"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
@ -25,7 +26,7 @@ var (
)
func TestDecodeStore(t *testing.T) {
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
cdc := encodingConfig.Codec
dec := simulation.NewDecodeStore(cdc)
ac := addresscodec.NewBech32Codec("cosmos")

Some files were not shown because too many files have changed in this diff Show More