feat!: Provide logger through depinject (#15818)
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
8e896f4d31
commit
af3122aa6c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user