feat!: Provide logger through depinject (#15818)
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
8e896f4d31
commit
af3122aa6c
@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Features
|
||||
|
||||
* (runtime) [#15818](https://github.com/cosmos/cosmos-sdk/pull/15818) Provide logger through `depinject` instead of appBuilder.
|
||||
* (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) Add status endpoint for clients.
|
||||
* (testutil/integration) [#15556](https://github.com/cosmos/cosmos-sdk/pull/15556) Introduce `testutil/integration` package for module integration testing.
|
||||
* (types) [#15735](https://github.com/cosmos/cosmos-sdk/pull/15735) Make `ValidateBasic() error` method of `Msg` interface optional. Modules should validate messages directly in their message handlers ([RFC 001](https://docs.cosmos.network/main/rfc/rfc-001-tx-validation)).
|
||||
@ -110,6 +111,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (x/bank) [#15818](https://github.com/cosmos/cosmos-sdk/issues/15818) `BaseViewKeeper`'s `Logger` method now doesn't require a context. `NewBaseKeeper`, `NewBaseSendKeeper` and `NewBaseViewKeeper` now also require a `log.Logger` to be passed in.
|
||||
* (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) `RegisterNodeService` now requires a config parameter.
|
||||
* (x/*all*) [#15648](https://github.com/cosmos/cosmos-sdk/issues/15648) Make `SetParams` consistent across all modules and validate the params at the message handling instead of `SetParams` method.
|
||||
* (x/genutil) [#15679](https://github.com/cosmos/cosmos-sdk/pull/15679) `MigrateGenesisCmd` now takes a `MigrationMap` instead of having the SDK genesis migration hardcoded.
|
||||
|
||||
24
UPGRADING.md
24
UPGRADING.md
@ -86,6 +86,30 @@ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
|
||||
)
|
||||
```
|
||||
|
||||
The following modules `NewKeeper` function now also take a `log.Logger`:
|
||||
|
||||
* `x/bank`
|
||||
|
||||
|
||||
### depinject
|
||||
|
||||
For `depinject` users, now the logger must be supplied through the main `depinject.Inject` function instead of passing it to `appBuilder.Build`.
|
||||
|
||||
```diff
|
||||
appConfig = depinject.Configs(
|
||||
AppConfig,
|
||||
depinject.Supply(
|
||||
// supply the application options
|
||||
appOpts,
|
||||
+ logger,
|
||||
...
|
||||
```
|
||||
|
||||
```diff
|
||||
- app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)
|
||||
+ app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
||||
```
|
||||
|
||||
### Packages
|
||||
|
||||
#### Store
|
||||
|
||||
@ -82,14 +82,18 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
err error
|
||||
)
|
||||
|
||||
err = depinject.Inject(configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
),
|
||||
err = depinject.Inject(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&bankKeeper,
|
||||
&accountKeeper,
|
||||
&interfaceRegistry,
|
||||
@ -99,7 +103,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
&appBuilder)
|
||||
require.NoError(t, err)
|
||||
|
||||
bapp := appBuilder.Build(log.NewNopLogger(), dbm.NewMemDB(), nil)
|
||||
bapp := appBuilder.Build(dbm.NewMemDB(), nil)
|
||||
err = bapp.Load(true)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
@ -55,10 +56,15 @@ func TestGRPCQueryRouter(t *testing.T) {
|
||||
func TestRegisterQueryServiceTwice(t *testing.T) {
|
||||
// Setup baseapp.
|
||||
var appBuilder *runtime.AppBuilder
|
||||
err := depinject.Inject(makeMinimalConfig(), &appBuilder)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
makeMinimalConfig(),
|
||||
depinject.Supply(log.NewTestLogger(t)),
|
||||
),
|
||||
&appBuilder)
|
||||
require.NoError(t, err)
|
||||
db := dbm.NewMemDB()
|
||||
app := appBuilder.Build(log.NewTestLogger(t), db, nil)
|
||||
app := appBuilder.Build(db, nil)
|
||||
|
||||
// First time registering service shouldn't panic.
|
||||
require.NotPanics(t, func() {
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -27,9 +28,13 @@ func TestRegisterMsgService(t *testing.T) {
|
||||
appBuilder *runtime.AppBuilder
|
||||
registry codectypes.InterfaceRegistry
|
||||
)
|
||||
err := depinject.Inject(makeMinimalConfig(), &appBuilder, ®istry)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
makeMinimalConfig(),
|
||||
depinject.Supply(log.NewTestLogger(t)),
|
||||
), &appBuilder, ®istry)
|
||||
require.NoError(t, err)
|
||||
app := appBuilder.Build(log.NewTestLogger(t), dbm.NewMemDB(), nil)
|
||||
app := appBuilder.Build(dbm.NewMemDB(), nil)
|
||||
|
||||
require.Panics(t, func() {
|
||||
testdata.RegisterMsgServer(
|
||||
@ -55,10 +60,14 @@ func TestRegisterMsgServiceTwice(t *testing.T) {
|
||||
appBuilder *runtime.AppBuilder
|
||||
registry codectypes.InterfaceRegistry
|
||||
)
|
||||
err := depinject.Inject(makeMinimalConfig(), &appBuilder, ®istry)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
makeMinimalConfig(),
|
||||
depinject.Supply(log.NewTestLogger(t)),
|
||||
), &appBuilder, ®istry)
|
||||
require.NoError(t, err)
|
||||
db := dbm.NewMemDB()
|
||||
app := appBuilder.Build(log.NewTestLogger(t), db, nil)
|
||||
app := appBuilder.Build(db, nil)
|
||||
testdata.RegisterInterfaces(registry)
|
||||
|
||||
// First time registering service shouldn't panic.
|
||||
@ -86,9 +95,13 @@ func TestMsgService(t *testing.T) {
|
||||
cdc codec.ProtoCodecMarshaler
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
)
|
||||
err := depinject.Inject(makeMinimalConfig(), &appBuilder, &cdc, &interfaceRegistry)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
makeMinimalConfig(),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &appBuilder, &cdc, &interfaceRegistry)
|
||||
require.NoError(t, err)
|
||||
app := appBuilder.Build(log.NewNopLogger(), dbm.NewMemDB(), nil)
|
||||
app := appBuilder.Build(dbm.NewMemDB(), nil)
|
||||
|
||||
// patch in TxConfig instead of using an output from x/auth/tx
|
||||
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
|
||||
|
||||
@ -52,10 +52,15 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
// TODO duplicated from testutils/sims/app_helpers.go
|
||||
// need more composable startup options for simapp, this test needed a handle to the closed over genesis account
|
||||
// to query balances
|
||||
err := depinject.Inject(testutil.AppConfig, &interfaceRegistry, &bankKeeper, &appBuilder, &cdc)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&interfaceRegistry, &bankKeeper, &appBuilder, &cdc)
|
||||
s.NoError(err)
|
||||
|
||||
app := appBuilder.Build(log.NewNopLogger(), dbm.NewMemDB(), nil)
|
||||
app := appBuilder.Build(dbm.NewMemDB(), nil)
|
||||
err = app.Load(true)
|
||||
s.NoError(err)
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
"github.com/cosmos/cosmos-sdk/crypto"
|
||||
@ -75,7 +77,11 @@ func TestArmorUnarmorPrivKey(t *testing.T) {
|
||||
func TestArmorUnarmorPubKey(t *testing.T) {
|
||||
// Select the encryption and storage for your cryptostore
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(configurator.NewAppConfig(), &cdc)
|
||||
|
||||
err := depinject.Inject(depinject.Configs(
|
||||
configurator.NewAppConfig(),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &cdc)
|
||||
require.NoError(t, err)
|
||||
|
||||
cstore := keyring.NewInMemory(cdc)
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -354,7 +356,11 @@ func TestDisplay(t *testing.T) {
|
||||
|
||||
require.NotEmpty(msig.String())
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(configurator.NewAppConfig(), &cdc)
|
||||
err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &cdc)
|
||||
require.NoError(err)
|
||||
bz, err := cdc.MarshalInterfaceJSON(msig)
|
||||
require.NoError(err)
|
||||
|
||||
@ -166,6 +166,34 @@ the block or app hash is left to the runtime to specify).
|
||||
Events emitted by `EmitKVEvent` and `EmitProtoEventNonConsensus` are not considered to be part of consensus and cannot be observed
|
||||
by other modules. If there is a client-side need to add events in patch releases, these methods can be used.
|
||||
|
||||
#### Logger
|
||||
|
||||
A logger (`cosmossdk.io/log`) must be supplied using `depinject`, and will
|
||||
be made available for modules to use via `depinject.In`.
|
||||
Modules using it should follow the current pattern in the SDK by adding the module name before using it.
|
||||
|
||||
```go
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Logger log.Logger
|
||||
}
|
||||
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
keeper := keeper.NewKeeper(
|
||||
in.logger,
|
||||
)
|
||||
}
|
||||
|
||||
func NewKeeper(logger log.Logger) Keeper {
|
||||
return Keeper{
|
||||
logger: logger.With(log.ModuleKey, "x/"+types.ModuleName),
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### Core `AppModule` extension interfaces
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
|
||||
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
|
||||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"golang.org/x/exp/slices"
|
||||
@ -47,6 +49,7 @@ type App struct {
|
||||
baseAppOptions []BaseAppOption
|
||||
msgServiceRouter *baseapp.MsgServiceRouter
|
||||
appConfig *appv1alpha1.Config
|
||||
logger log.Logger
|
||||
// initChainer is the init chainer function defined by the app config.
|
||||
// this is only required if the chain wants to add special InitChainer logic.
|
||||
initChainer sdk.InitChainer
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -26,7 +25,6 @@ func (a *AppBuilder) DefaultGenesis() map[string]json.RawMessage {
|
||||
|
||||
// Build builds an *App instance.
|
||||
func (a *AppBuilder) Build(
|
||||
logger log.Logger,
|
||||
db dbm.DB,
|
||||
traceStore io.Writer,
|
||||
baseAppOptions ...func(*baseapp.BaseApp),
|
||||
@ -35,7 +33,7 @@ func (a *AppBuilder) Build(
|
||||
baseAppOptions = append(baseAppOptions, option)
|
||||
}
|
||||
|
||||
bApp := baseapp.NewBaseApp(a.app.config.AppName, logger, db, nil, baseAppOptions...)
|
||||
bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...)
|
||||
bApp.SetMsgServiceRouter(a.app.msgServiceRouter)
|
||||
bApp.SetCommitMultiStoreTracer(traceStore)
|
||||
bApp.SetVersion(version.Version)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -127,6 +128,7 @@ type AppInputs struct {
|
||||
BaseAppOptions []BaseAppOption
|
||||
InterfaceRegistry codectypes.InterfaceRegistry
|
||||
LegacyAmino *codec.LegacyAmino
|
||||
Logger log.Logger
|
||||
}
|
||||
|
||||
func SetupAppBuilder(inputs AppInputs) {
|
||||
@ -135,6 +137,7 @@ func SetupAppBuilder(inputs AppInputs) {
|
||||
app.config = inputs.Config
|
||||
app.ModuleManager = module.NewManagerFromMap(inputs.Modules)
|
||||
app.appConfig = inputs.AppConfig
|
||||
app.logger = inputs.Logger
|
||||
|
||||
for name, mod := range inputs.Modules {
|
||||
if basicMod, ok := mod.(module.AppModuleBasic); ok {
|
||||
|
||||
@ -291,6 +291,7 @@ func NewSimApp(
|
||||
app.AccountKeeper,
|
||||
BlockedAddresses(),
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
logger,
|
||||
)
|
||||
app.StakingKeeper = stakingkeeper.NewKeeper(
|
||||
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
|
||||
@ -168,6 +168,7 @@ func NewSimApp(
|
||||
depinject.Supply(
|
||||
// supply the application options
|
||||
appOpts,
|
||||
logger,
|
||||
|
||||
// ADVANCED CONFIGURATION
|
||||
|
||||
@ -248,7 +249,7 @@ func NewSimApp(
|
||||
// }
|
||||
// baseAppOptions = append(baseAppOptions, prepareOpt)
|
||||
|
||||
app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)
|
||||
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
||||
|
||||
// register streaming services
|
||||
if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil {
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
|
||||
|
||||
@ -57,7 +57,12 @@ func (s *E2ETestSuite) SetupSuite() {
|
||||
appBuilder *runtime.AppBuilder
|
||||
paramsKeeper keeper.Keeper
|
||||
)
|
||||
if err := depinject.Inject(AppConfig, &appBuilder, ¶msKeeper); err != nil {
|
||||
if err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
AppConfig,
|
||||
depinject.Supply(val.GetCtx().Logger),
|
||||
),
|
||||
&appBuilder, ¶msKeeper); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -66,7 +71,6 @@ func (s *E2ETestSuite) SetupSuite() {
|
||||
subspace := paramsKeeper.Subspace(mySubspace).WithKeyTable(paramtypes.NewKeyTable().RegisterParamSet(¶mSet))
|
||||
|
||||
app := appBuilder.Build(
|
||||
val.GetCtx().Logger,
|
||||
dbm.NewMemDB(),
|
||||
nil,
|
||||
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
"gotest.tools/v3/assert"
|
||||
"pgregory.net/rapid"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
@ -62,13 +64,16 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
app, err := simstestutil.Setup(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&f.bankKeeper,
|
||||
&interfaceRegistry,
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
@ -118,13 +120,16 @@ func initFixture(t assert.TestingT) *fixture {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
app, err := sims.Setup(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.VestingModule()),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.VestingModule()),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&f.accountKeeper, &f.bankKeeper, &f.stakingKeeper,
|
||||
&f.appCodec, &f.authConfig, &interfaceRegistry,
|
||||
)
|
||||
@ -165,7 +170,7 @@ func initKeepersWithmAccPerms(f *fixture, blockedAddrs map[string]bool) (authkee
|
||||
maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
bankKeeper := keeper.NewBaseKeeper(
|
||||
appCodec, f.fetchStoreKey(types.StoreKey), authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
appCodec, f.fetchStoreKey(types.StoreKey), authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), log.NewNopLogger(),
|
||||
)
|
||||
|
||||
return authKeeper, bankKeeper
|
||||
@ -1205,6 +1210,7 @@ func TestBalanceTrackingEvents(t *testing.T) {
|
||||
|
||||
f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, f.fetchStoreKey(types.StoreKey),
|
||||
f.accountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
log.NewNopLogger(),
|
||||
)
|
||||
|
||||
// set account with multiple permissions
|
||||
@ -1372,6 +1378,7 @@ func TestMintCoinRestrictions(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, f.fetchStoreKey(types.StoreKey),
|
||||
f.accountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
log.NewNopLogger(),
|
||||
).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn))
|
||||
for _, testCase := range test.testCases {
|
||||
if testCase.expectPass {
|
||||
|
||||
@ -92,6 +92,7 @@ func initFixture(t testing.TB) *fixture {
|
||||
accountKeeper,
|
||||
blockedAddresses,
|
||||
authority.String(),
|
||||
log.NewNopLogger(),
|
||||
)
|
||||
|
||||
stakingKeeper := stakingkeeper.NewKeeper(cdc, keys[stakingtypes.StoreKey], accountKeeper, bankKeeper, authority.String())
|
||||
|
||||
@ -3,6 +3,8 @@ package distribution_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
@ -16,7 +18,12 @@ import (
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
var accountKeeper authkeeper.AccountKeeper
|
||||
|
||||
app, err := simtestutil.SetupAtGenesis(testutil.AppConfig, &accountKeeper)
|
||||
app, err := simtestutil.SetupAtGenesis(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&accountKeeper)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, cmtproto.Header{})
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/x/evidence/exported"
|
||||
"cosmossdk.io/x/evidence/keeper"
|
||||
"cosmossdk.io/x/evidence/testutil"
|
||||
@ -63,7 +65,11 @@ func initFixture(t assert.TestingT) *fixture {
|
||||
f := &fixture{}
|
||||
var evidenceKeeper keeper.Keeper
|
||||
|
||||
app, err := simtestutil.Setup(testutil.AppConfig,
|
||||
app, err := simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&evidenceKeeper,
|
||||
&f.interfaceRegistry,
|
||||
&f.accountKeeper,
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -61,13 +63,17 @@ func initFixture(t assert.TestingT) *fixture {
|
||||
encCfg := moduletestutil.TestEncodingConfig{}
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule()),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&encCfg.InterfaceRegistry, &encCfg.Codec, &encCfg.TxConfig, &encCfg.Amino,
|
||||
&f.accountKeeper, &f.bankKeeper, &f.stakingKeeper)
|
||||
|
||||
@ -8,6 +8,9 @@ import (
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
@ -60,7 +63,10 @@ func TestImportExportQueues(t *testing.T) {
|
||||
|
||||
s1 := suite{}
|
||||
s1.app, err = simtestutil.SetupWithConfiguration(
|
||||
appConfig,
|
||||
depinject.Configs(
|
||||
appConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&s1.AccountKeeper, &s1.BankKeeper, &s1.DistrKeeper, &s1.GovKeeper, &s1.StakingKeeper, &s1.cdc, &s1.appBuilder,
|
||||
)
|
||||
@ -113,7 +119,10 @@ func TestImportExportQueues(t *testing.T) {
|
||||
|
||||
s2 := suite{}
|
||||
s2.app, err = simtestutil.SetupWithConfiguration(
|
||||
appConfig,
|
||||
depinject.Configs(
|
||||
appConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&s2.AccountKeeper, &s2.BankKeeper, &s2.DistrKeeper, &s2.GovKeeper, &s2.StakingKeeper, &s2.cdc, &s2.appBuilder,
|
||||
)
|
||||
|
||||
@ -3,6 +3,8 @@ package gov_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
@ -18,14 +20,17 @@ import (
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
var accountKeeper authkeeper.AccountKeeper
|
||||
app, err := simtestutil.SetupAtGenesis(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.DistributionModule(),
|
||||
configurator.ConsensusModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.DistributionModule(),
|
||||
configurator.ConsensusModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&accountKeeper,
|
||||
)
|
||||
|
||||
@ -13,6 +13,8 @@ import (
|
||||
|
||||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -41,13 +43,16 @@ func initFixture(t assert.TestingT) *fixture {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
app, err := simtestutil.Setup(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&interfaceRegistry,
|
||||
)
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
@ -35,7 +37,10 @@ type fixture struct {
|
||||
func initFixture(t assert.TestingT) *fixture {
|
||||
f := &fixture{}
|
||||
app, err := simtestutil.Setup(
|
||||
testutil.AppConfig,
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&f.bankKeeper,
|
||||
&f.slashingKeeper,
|
||||
&f.stakingKeeper,
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
@ -51,7 +53,10 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
app, err := simtestutil.Setup(
|
||||
stakingtestutil.AppConfig,
|
||||
depinject.Configs(
|
||||
stakingtestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&f.bankKeeper,
|
||||
&f.accountKeeper,
|
||||
&f.stakingKeeper,
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -25,13 +27,16 @@ func TestCancelUnbondingDelegation(t *testing.T) {
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
)
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&stakingKeeper, &bankKeeper, &accountKeeper)
|
||||
|
||||
@ -3,6 +3,8 @@ package keeper
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
@ -15,13 +17,16 @@ import (
|
||||
func TestParams(t *testing.T) {
|
||||
var stakingKeeper *keeper.Keeper
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.BankModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.AuthModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&stakingKeeper)
|
||||
|
||||
@ -182,7 +182,11 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
)
|
||||
|
||||
if err := depinject.Inject(appConfig,
|
||||
if err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
appConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&appBuilder,
|
||||
&txConfig,
|
||||
&cdc,
|
||||
@ -203,11 +207,15 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
|
||||
cfg.AppConstructor = func(val ValidatorI) servertypes.Application {
|
||||
// we build a unique app instance for every validator here
|
||||
var appBuilder *runtime.AppBuilder
|
||||
if err := depinject.Inject(appConfig, &appBuilder); err != nil {
|
||||
if err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
appConfig,
|
||||
depinject.Supply(val.GetCtx().Logger),
|
||||
),
|
||||
&appBuilder); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
app := appBuilder.Build(
|
||||
val.GetCtx().Logger,
|
||||
dbm.NewMemDB(),
|
||||
nil,
|
||||
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
|
||||
|
||||
@ -13,7 +13,6 @@ import (
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -118,17 +117,14 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
|
||||
codec codec.Codec
|
||||
)
|
||||
|
||||
if err := depinject.Inject(
|
||||
appConfig,
|
||||
append(extraOutputs, &appBuilder, &codec)...,
|
||||
); err != nil {
|
||||
if err := depinject.Inject(appConfig, append(extraOutputs, &appBuilder, &codec)...); err != nil {
|
||||
return nil, fmt.Errorf("failed to inject dependencies: %w", err)
|
||||
}
|
||||
|
||||
if startupConfig.BaseAppOption != nil {
|
||||
app = appBuilder.Build(log.NewNopLogger(), startupConfig.DB, nil, startupConfig.BaseAppOption)
|
||||
app = appBuilder.Build(startupConfig.DB, nil, startupConfig.BaseAppOption)
|
||||
} else {
|
||||
app = appBuilder.Build(log.NewNopLogger(), startupConfig.DB, nil)
|
||||
app = appBuilder.Build(startupConfig.DB, nil)
|
||||
}
|
||||
if err := app.Load(true); err != nil {
|
||||
return nil, fmt.Errorf("failed to load app: %w", err)
|
||||
|
||||
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -65,12 +67,15 @@ func (s *paginationTestSuite) SetupTest() {
|
||||
)
|
||||
|
||||
app, err := testutilsims.Setup(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.OmitInitGenesis(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.OmitInitGenesis(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&bankKeeper, &accountKeeper, ®, &cdc)
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
@ -57,7 +59,10 @@ func TestMigrateVestingAccounts(t *testing.T) {
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
)
|
||||
app, err := simtestutil.Setup(
|
||||
authtestutil.AppConfig,
|
||||
depinject.Configs(
|
||||
authtestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&accountKeeper,
|
||||
&bankKeeper,
|
||||
&stakingKeeper,
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
@ -50,7 +52,10 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
|
||||
var accountKeeper keeper.AccountKeeper
|
||||
|
||||
app, err := simtestutil.Setup(
|
||||
authtestutil.AppConfig,
|
||||
depinject.Configs(
|
||||
authtestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&accountKeeper,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -3,6 +3,8 @@ package auth_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -14,7 +16,12 @@ import (
|
||||
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
var accountKeeper keeper.AccountKeeper
|
||||
app, err := simtestutil.SetupAtGenesis(testutil.AppConfig, &accountKeeper)
|
||||
app, err := simtestutil.SetupAtGenesis(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, cmtproto.Header{})
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
@ -31,7 +32,10 @@ func TestDecodeStore(t *testing.T) {
|
||||
cdc codec.Codec
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
)
|
||||
err := depinject.Inject(testutil.AppConfig, &cdc, &accountKeeper)
|
||||
err := depinject.Inject(depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &cdc, &accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
acc := types.NewBaseAccountWithAddress(delAddr1)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
@ -67,7 +68,10 @@ func TestBaseSequence(t *testing.T) {
|
||||
|
||||
func TestBaseAccountMarshal(t *testing.T) {
|
||||
var accountKeeper authkeeper.AccountKeeper
|
||||
err := depinject.Inject(testutil.AppConfig, &accountKeeper)
|
||||
err := depinject.Inject(depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, pub, addr := testdata.KeyTestPubAddr()
|
||||
|
||||
@ -5,6 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -43,7 +45,10 @@ type SimTestSuite struct {
|
||||
|
||||
func (suite *SimTestSuite) SetupTest() {
|
||||
app, err := simtestutil.Setup(
|
||||
testutil.AppConfig,
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&suite.legacyAmino,
|
||||
&suite.codec,
|
||||
&suite.interfaceRegistry,
|
||||
|
||||
@ -3,6 +3,8 @@ package bank_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -109,16 +111,20 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s
|
||||
startupCfg := simtestutil.DefaultStartUpConfig()
|
||||
startupCfg.GenesisAccounts = genAccounts
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.DistributionModule(),
|
||||
),
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.DistributionModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
startupCfg, &res.BankKeeper, &res.AccountKeeper, &res.DistributionKeeper)
|
||||
|
||||
res.App = app
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
@ -59,6 +60,7 @@ type BaseKeeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey storetypes.StoreKey
|
||||
mintCoinsRestrictionFn MintingRestrictionFn
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
type MintingRestrictionFn func(ctx sdk.Context, coins sdk.Coins) error
|
||||
@ -89,17 +91,22 @@ func NewBaseKeeper(
|
||||
ak types.AccountKeeper,
|
||||
blockedAddrs map[string]bool,
|
||||
authority string,
|
||||
logger log.Logger,
|
||||
) BaseKeeper {
|
||||
if _, err := sdk.AccAddressFromBech32(authority); err != nil {
|
||||
panic(fmt.Errorf("invalid bank authority address: %w", err))
|
||||
}
|
||||
|
||||
// add the module name to the logger
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
|
||||
return BaseKeeper{
|
||||
BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, blockedAddrs, authority),
|
||||
BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, blockedAddrs, authority, logger),
|
||||
ak: ak,
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
mintCoinsRestrictionFn: func(ctx sdk.Context, coins sdk.Coins) error { return nil },
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +354,7 @@ func (k BaseKeeper) UndelegateCoinsFromModuleToAccount(
|
||||
func (k BaseKeeper) MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error {
|
||||
err := k.mintCoinsRestrictionFn(ctx, amounts)
|
||||
if err != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Module %q attempted to mint coins %s it doesn't have permission for, error %v", moduleName, amounts, err))
|
||||
k.logger.Error(fmt.Sprintf("Module %q attempted to mint coins %s it doesn't have permission for, error %v", moduleName, amounts, err))
|
||||
return err
|
||||
}
|
||||
acc := k.ak.GetModuleAccount(ctx, moduleName)
|
||||
@ -370,8 +377,7 @@ func (k BaseKeeper) MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Co
|
||||
k.setSupply(ctx, supply)
|
||||
}
|
||||
|
||||
logger := k.Logger(ctx)
|
||||
logger.Debug("minted coins from module account", "amount", amounts.String(), "from", moduleName)
|
||||
k.logger.Debug("minted coins from module account", "amount", amounts.String(), "from", moduleName)
|
||||
|
||||
// emit mint event
|
||||
ctx.EventManager().EmitEvent(
|
||||
@ -404,8 +410,7 @@ func (k BaseKeeper) BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Co
|
||||
k.setSupply(ctx, supply)
|
||||
}
|
||||
|
||||
logger := k.Logger(ctx)
|
||||
logger.Debug("burned tokens from module account", "amount", amounts.String(), "from", moduleName)
|
||||
k.logger.Debug("burned tokens from module account", "amount", amounts.String(), "from", moduleName)
|
||||
|
||||
// emit burn event
|
||||
ctx.EventManager().EmitEvent(
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
@ -139,6 +140,7 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
suite.authKeeper,
|
||||
map[string]bool{accAddrs[4].String(): true},
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
log.NewNopLogger(),
|
||||
)
|
||||
|
||||
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)
|
||||
@ -240,6 +242,7 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
|
||||
nil,
|
||||
nil,
|
||||
authority,
|
||||
log.NewNopLogger(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
@ -53,6 +54,7 @@ type BaseSendKeeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
ak types.AccountKeeper
|
||||
storeKey storetypes.StoreKey
|
||||
logger log.Logger
|
||||
|
||||
// list of addresses that are restricted from receiving transactions
|
||||
blockedAddrs map[string]bool
|
||||
@ -68,18 +70,20 @@ func NewBaseSendKeeper(
|
||||
ak types.AccountKeeper,
|
||||
blockedAddrs map[string]bool,
|
||||
authority string,
|
||||
logger log.Logger,
|
||||
) BaseSendKeeper {
|
||||
if _, err := sdk.AccAddressFromBech32(authority); err != nil {
|
||||
panic(fmt.Errorf("invalid bank authority address: %w", err))
|
||||
}
|
||||
|
||||
return BaseSendKeeper{
|
||||
BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak),
|
||||
BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak, logger),
|
||||
cdc: cdc,
|
||||
ak: ak,
|
||||
storeKey: storeKey,
|
||||
blockedAddrs: blockedAddrs,
|
||||
authority: authority,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections/indexes"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
|
||||
@ -11,7 +12,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
@ -64,6 +64,7 @@ type BaseViewKeeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey storetypes.StoreKey
|
||||
ak types.AccountKeeper
|
||||
logger log.Logger
|
||||
|
||||
Schema collections.Schema
|
||||
Supply collections.Map[string, math.Int]
|
||||
@ -74,12 +75,13 @@ type BaseViewKeeper struct {
|
||||
}
|
||||
|
||||
// NewBaseViewKeeper returns a new BaseViewKeeper.
|
||||
func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper) BaseViewKeeper {
|
||||
func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, logger log.Logger) BaseViewKeeper {
|
||||
sb := collections.NewSchemaBuilder(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)))
|
||||
k := BaseViewKeeper{
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
ak: ak,
|
||||
logger: logger,
|
||||
Supply: collections.NewMap(sb, types.SupplyKey, "supply", collections.StringKey, sdk.IntValue),
|
||||
DenomMetadata: collections.NewMap(sb, types.DenomMetadataPrefix, "denom_metadata", collections.StringKey, codec.CollValue[types.Metadata](cdc)),
|
||||
SendEnabled: collections.NewMap(sb, types.SendEnabledPrefix, "send_enabled", collections.StringKey, codec.BoolValue), // NOTE: we use a bool value which uses protobuf to retain state backwards compat
|
||||
@ -95,16 +97,16 @@ func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak t
|
||||
return k
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k BaseViewKeeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+types.ModuleName)
|
||||
}
|
||||
|
||||
// HasBalance returns whether or not an account has at least amt balance.
|
||||
func (k BaseViewKeeper) HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool {
|
||||
return k.GetBalance(ctx, addr, amt.Denom).IsGTE(amt)
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k BaseViewKeeper) Logger() log.Logger {
|
||||
return k.logger
|
||||
}
|
||||
|
||||
// GetAllBalances returns all the account balances for the given account address.
|
||||
func (k BaseViewKeeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins {
|
||||
balances := sdk.NewCoins()
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
modulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
@ -212,6 +213,7 @@ type ModuleInputs struct {
|
||||
Config *modulev1.Module
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
Logger log.Logger
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
|
||||
@ -254,6 +256,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
in.AccountKeeper,
|
||||
blockedAddresses,
|
||||
authority.String(),
|
||||
in.Logger,
|
||||
)
|
||||
m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper, in.LegacySubspace)
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -43,14 +45,18 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
appBuilder *runtime.AppBuilder
|
||||
err error
|
||||
)
|
||||
suite.app, err = simtestutil.Setup(configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.TxModule(),
|
||||
), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &suite.txConfig, &appBuilder)
|
||||
suite.app, err = simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.TxModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &suite.txConfig, &appBuilder)
|
||||
|
||||
suite.NoError(err)
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
@ -234,7 +236,12 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
appBuilder *runtime.AppBuilder
|
||||
err error
|
||||
)
|
||||
suite.app, err = simtestutil.Setup(distrtestutil.AppConfig, &suite.accountKeeper,
|
||||
suite.app, err = simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
distrtestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&suite.accountKeeper,
|
||||
&suite.bankKeeper,
|
||||
&suite.cdc,
|
||||
&appBuilder,
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/x/evidence/keeper"
|
||||
"cosmossdk.io/x/evidence/simulation"
|
||||
"cosmossdk.io/x/evidence/testutil"
|
||||
@ -19,7 +20,10 @@ import (
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
var evidenceKeeper keeper.Keeper
|
||||
err := depinject.Inject(testutil.AppConfig, &evidenceKeeper)
|
||||
err := depinject.Inject(depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &evidenceKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
dec := simulation.NewDecodeStore(evidenceKeeper)
|
||||
|
||||
@ -6,7 +6,11 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
sdklog "cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
@ -29,7 +33,6 @@ import (
|
||||
_ "github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -112,14 +115,17 @@ func createTestSuite(t *testing.T) suite {
|
||||
res := suite{}
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.DistributionModule(),
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GovModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.DistributionModule(),
|
||||
),
|
||||
depinject.Supply(sdklog.NewNopLogger()),
|
||||
),
|
||||
simtestutil.DefaultStartUpConfig(),
|
||||
&res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.DistributionKeeper, &res.StakingKeeper,
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -382,16 +384,21 @@ type suite struct {
|
||||
func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) {
|
||||
res := suite{}
|
||||
|
||||
app, err := simtestutil.Setup(configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.DistributionModule(),
|
||||
configurator.GovModule(),
|
||||
), &res.TxConfig, &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.DistributionKeeper)
|
||||
app, err := simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.DistributionModule(),
|
||||
configurator.GovModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&res.TxConfig, &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.DistributionKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(isCheckTx, cmtproto.Header{})
|
||||
|
||||
@ -6,9 +6,13 @@ import (
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
cmttime "github.com/cometbft/cometbft/types/time"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
@ -22,7 +26,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/group/module"
|
||||
grouptestutil "github.com/cosmos/cosmos-sdk/x/group/testutil"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
@ -45,7 +48,10 @@ func TestIntegrationTestSuite(t *testing.T) {
|
||||
|
||||
func (s *IntegrationTestSuite) SetupTest() {
|
||||
app, err := simtestutil.Setup(
|
||||
grouptestutil.AppConfig,
|
||||
depinject.Configs(
|
||||
grouptestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&s.interfaceRegistry,
|
||||
&s.bankKeeper,
|
||||
&s.stakingKeeper,
|
||||
|
||||
@ -5,6 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -42,7 +44,10 @@ type SimTestSuite struct {
|
||||
|
||||
func (suite *SimTestSuite) SetupTest() {
|
||||
app, err := simtestutil.Setup(
|
||||
grouptestutil.AppConfig,
|
||||
depinject.Configs(
|
||||
grouptestutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&suite.codec,
|
||||
&suite.interfaceRegistry,
|
||||
&suite.txConfig,
|
||||
|
||||
@ -3,6 +3,8 @@ package mint_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -16,7 +18,11 @@ import (
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
var accountKeeper authkeeper.AccountKeeper
|
||||
|
||||
app, err := simtestutil.SetupAtGenesis(testutil.AppConfig, &accountKeeper)
|
||||
app, err := simtestutil.SetupAtGenesis(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, cmtproto.Header{})
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -27,7 +29,10 @@ func TestBeginBlocker(t *testing.T) {
|
||||
var slashingKeeper slashingkeeper.Keeper
|
||||
|
||||
app, err := simtestutil.Setup(
|
||||
testutil.AppConfig,
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&interfaceRegistry,
|
||||
&bankKeeper,
|
||||
&stakingKeeper,
|
||||
|
||||
@ -4,11 +4,14 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
@ -51,15 +54,21 @@ func TestSlashingMsgs(t *testing.T) {
|
||||
slashingKeeper keeper.Keeper
|
||||
)
|
||||
|
||||
app, err := sims.SetupWithConfiguration(configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.SlashingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule()),
|
||||
app, err := sims.SetupWithConfiguration(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.ParamsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.SlashingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.BankModule(),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
startupCfg, &stakingKeeper, &bankKeeper, &slashingKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
baseApp := app.BaseApp
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ import (
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -78,7 +80,10 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
startupCfg.ValidatorSet = createValidator
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
testutil.AppConfig,
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
startupCfg,
|
||||
&suite.legacyAmino,
|
||||
&suite.codec,
|
||||
|
||||
@ -5,12 +5,16 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
@ -53,7 +57,12 @@ func TestStakingMsgs(t *testing.T) {
|
||||
startupCfg := simtestutil.DefaultStartUpConfig()
|
||||
startupCfg.GenesisAccounts = accs
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(testutil.AppConfig, startupCfg, &bankKeeper, &stakingKeeper)
|
||||
app, err := simtestutil.SetupWithConfiguration(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
startupCfg, &bankKeeper, &stakingKeeper)
|
||||
require.NoError(t, err)
|
||||
ctxCheck := app.BaseApp.NewContext(true, cmtproto.Header{})
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ package staking_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -15,7 +17,11 @@ import (
|
||||
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
var accountKeeper authKeeper.AccountKeeper
|
||||
app, err := simtestutil.SetupAtGenesis(testutil.AppConfig, &accountKeeper)
|
||||
app, err := simtestutil.SetupAtGenesis(
|
||||
depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
), &accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, cmtproto.Header{})
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
sdklog "cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -13,6 +15,7 @@ import (
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
@ -88,7 +91,12 @@ func (s *SimTestSuite) SetupTest() {
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
)
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(testutil.AppConfig, startupCfg, &s.txConfig, &bankKeeper, &accountKeeper, &mintKeeper, &distrKeeper, &stakingKeeper)
|
||||
cfg := depinject.Configs(
|
||||
testutil.AppConfig,
|
||||
depinject.Supply(sdklog.NewNopLogger()),
|
||||
)
|
||||
|
||||
app, err := simtestutil.SetupWithConfiguration(cfg, startupCfg, &s.txConfig, &bankKeeper, &accountKeeper, &mintKeeper, &distrKeeper, &stakingKeeper)
|
||||
require.NoError(s.T(), err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, cmtproto.Header{})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user