diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 4adc20535cf9..846879b9562d 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -40,17 +40,6 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, return gasInfo, result, err } -func (app *BaseApp) SimTxFinalizeBlock(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { - // See comment for Check(). - bz, err := txEncoder(tx) - if err != nil { - return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) - } - - gasInfo, result, _, err := app.runTx(execModeFinalize, bz) - return gasInfo, result, err -} - // NewContextLegacy returns a new sdk.Context with the provided header func (app *BaseApp) NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context { if isCheckTx { diff --git a/tests/integration/bank/app_test.go b/tests/integration/bank/app_test.go index 62ce4c7b629f..68c39dd9d150 100644 --- a/tests/integration/bank/app_test.go +++ b/tests/integration/bank/app_test.go @@ -4,10 +4,10 @@ import ( "testing" abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/depinject" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" @@ -168,7 +168,7 @@ func TestSendNotEnoughBalance(t *testing.T) { origSeq := res1.GetSequence() sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) - header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} + header := header.Info{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() _, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) @@ -248,7 +248,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { for _, tc := range testCases { t.Logf("testing %s", tc.desc) - header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} + header := header.Info{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { @@ -300,7 +300,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { } for _, tc := range testCases { - header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} + header := header.Info{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -355,7 +355,7 @@ func TestMsgMultiSendDependent(t *testing.T) { } for _, tc := range testCases { - header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} + header := header.Info{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -434,7 +434,7 @@ func TestMsgSetSendEnabled(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(tt *testing.T) { - header := cmtproto.Header{Height: s.App.LastBlockHeight() + 1} + header := header.Info{Height: s.App.LastBlockHeight() + 1} txGen := moduletestutil.MakeTestTxConfig() _, _, err = simtestutil.SignCheckDeliver(tt, txGen, s.App.BaseApp, header, tc.msgs, "", []uint64{0}, tc.accSeqs, tc.expSimPass, tc.expPass, priv1) if len(tc.expInError) > 0 { diff --git a/testutil/sims/tx_helpers.go b/testutil/sims/tx_helpers.go index f334925bcec1..96a2054f638a 100644 --- a/testutil/sims/tx_helpers.go +++ b/testutil/sims/tx_helpers.go @@ -7,9 +7,9 @@ import ( "time" types2 "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/baseapp" @@ -93,7 +93,7 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee // the parameter 'expPass' against the result. A corresponding result is // returned. func SignCheckDeliver( - t *testing.T, txCfg client.TxConfig, app *baseapp.BaseApp, header types.Header, msgs []sdk.Msg, + t *testing.T, txCfg client.TxConfig, app *baseapp.BaseApp, header header.Info, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { t.Helper() diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index ae680a9ebfbd..ffc8fe97f849 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -7,12 +7,9 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/crypto" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -190,11 +187,6 @@ func TestDeductFeesNoDelegation(t *testing.T) { } } -// don't consume any gas -func SigGasNoConsumer(meter storetypes.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error { - return nil -} - func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey, ) (sdk.Tx, error) { diff --git a/x/auth/vesting/fuzz_test.go b/x/auth/vesting/fuzz_test.go index 4406ef647e55..4b6020b79630 100644 --- a/x/auth/vesting/fuzz_test.go +++ b/x/auth/vesting/fuzz_test.go @@ -5,11 +5,10 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" fuzz "github.com/google/gofuzz" + "cosmossdk.io/core/header" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -118,8 +117,7 @@ func FuzzMsgServerCreateVestingAccount(f *testing.F) { msgServer := NewMsgServerImpl(accountKeeper, bankKeeper) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) - + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) _, _ = msgServer.CreateVestingAccount(ctx, va) }) } diff --git a/x/auth/vesting/msg_server_test.go b/x/auth/vesting/msg_server_test.go index 7ca30a1a7f91..df4daedc2374 100644 --- a/x/auth/vesting/msg_server_test.go +++ b/x/auth/vesting/msg_server_test.go @@ -4,11 +4,10 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "cosmossdk.io/core/header" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -46,7 +45,8 @@ func (s *VestingTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(authtypes.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) + s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) + encCfg := moduletestutil.MakeTestEncodingConfig() maccPerms := map[string][]string{} diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index b0776c1d6d95..3366d1ea5a30 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - tmtime "github.com/cometbft/cometbft/types/time" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -66,7 +65,7 @@ func (s *VestingAccountTestSuite) SetupTest() { } func TestGetVestedCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() startTime := now.Add(24 * time.Hour) endTime := startTime.Add(24 * time.Hour) @@ -102,7 +101,7 @@ func TestGetVestedCoinsContVestingAcc(t *testing.T) { } func TestGetVestingCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() startTime := now.Add(24 * time.Hour) endTime := startTime.Add(24 * time.Hour) @@ -134,7 +133,7 @@ func TestGetVestingCoinsContVestingAcc(t *testing.T) { } func TestSpendableCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() startTime := now.Add(24 * time.Hour) endTime := startTime.Add(24 * time.Hour) @@ -166,7 +165,7 @@ func TestSpendableCoinsContVestingAcc(t *testing.T) { } func TestTrackDelegationContVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -207,7 +206,7 @@ func TestTrackDelegationContVestingAcc(t *testing.T) { } func TestTrackUndelegationContVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -255,7 +254,7 @@ func TestTrackUndelegationContVestingAcc(t *testing.T) { } func TestGetVestedCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -272,7 +271,7 @@ func TestGetVestedCoinsDelVestingAcc(t *testing.T) { } func TestGetVestingCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -289,7 +288,7 @@ func TestGetVestingCoinsDelVestingAcc(t *testing.T) { } func TestSpendableCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -319,7 +318,7 @@ func TestSpendableCoinsDelVestingAcc(t *testing.T) { } func TestTrackDelegationDelVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -357,7 +356,7 @@ func TestTrackDelegationDelVestingAcc(t *testing.T) { } func TestTrackUndelegationDelVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -406,7 +405,7 @@ func TestTrackUndelegationDelVestingAcc(t *testing.T) { } func TestGetVestedCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) periods := types.Periods{ types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, @@ -451,7 +450,7 @@ func TestGetVestedCoinsPeriodicVestingAcc(t *testing.T) { } func TestOverflowAndNegativeVestedCoinsPeriods(t *testing.T) { - now := tmtime.Now() + now := time.Now() tests := []struct { name string periods []types.Period @@ -502,7 +501,7 @@ func TestOverflowAndNegativeVestedCoinsPeriods(t *testing.T) { } func TestGetVestingCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) periods := types.Periods{ types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, @@ -540,7 +539,7 @@ func TestGetVestingCoinsPeriodicVestingAcc(t *testing.T) { } func TestSpendableCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) periods := types.Periods{ types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, @@ -568,7 +567,7 @@ func TestSpendableCoinsPeriodicVestingAcc(t *testing.T) { } func TestTrackDelegationPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) periods := types.Periods{ types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, @@ -630,7 +629,7 @@ func TestTrackDelegationPeriodicVestingAcc(t *testing.T) { } func TestTrackUndelegationPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) periods := types.Periods{ types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, @@ -691,7 +690,7 @@ func TestTrackUndelegationPeriodicVestingAcc(t *testing.T) { } func TestGetVestedCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(1000 * 24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -708,7 +707,7 @@ func TestGetVestedCoinsPermLockedVestingAcc(t *testing.T) { } func TestGetVestingCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(1000 * 24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -725,7 +724,7 @@ func TestGetVestingCoinsPermLockedVestingAcc(t *testing.T) { } func TestSpendableCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(1000 * 24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -750,7 +749,7 @@ func TestSpendableCoinsPermLockedVestingAcc(t *testing.T) { } func TestTrackDelegationPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(1000 * 24 * time.Hour) bacc, origCoins := initBaseAccount() @@ -780,7 +779,7 @@ func TestTrackDelegationPermLockedVestingAcc(t *testing.T) { } func TestTrackUndelegationPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() + now := time.Now() endTime := now.Add(1000 * 24 * time.Hour) bacc, origCoins := initBaseAccount() diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 67b3611e7af8..58c7cdcc092a 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "cosmossdk.io/core/header" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -46,7 +46,8 @@ func (suite *GenesisTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(keeper.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) - suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{}) // gomock initializations diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 4fb59812e63c..1bcebacd37c8 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -141,7 +141,7 @@ func SimulateMsgGrant( return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, "unable to generate mock tx"), nil, err } - _, _, err = app.SimTxFinalizeBlock(txCfg.TxEncoder(), tx) + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } @@ -218,7 +218,7 @@ func SimulateMsgRevoke( return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, err.Error()), nil, err } - _, _, err = app.SimTxFinalizeBlock(txCfg.TxEncoder(), tx) + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "unable to execute tx: "+err.Error()), nil, err } @@ -318,7 +318,7 @@ func SimulateMsgExec( return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err } - _, _, err = app.SimTxFinalizeBlock(txCfg.TxEncoder(), tx) + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err } diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index e5a1550cb087..8e0619f26c8e 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -123,11 +122,6 @@ func (suite *SimTestSuite) TestSimulateGrant() { blockTime := time.Now().UTC() ctx := suite.ctx.WithHeaderInfo(header.Info{Time: blockTime}) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) granter := accounts[0] grantee := accounts[1] @@ -150,12 +144,6 @@ func (suite *SimTestSuite) TestSimulateRevoke() { s := rand.NewSource(2) r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) initAmt := sdk.TokensFromConsensusPower(200000, sdk.DefaultPowerReduction) initCoins := sdk.NewCoins(sdk.NewCoin("stake", initAmt)) @@ -164,7 +152,7 @@ func (suite *SimTestSuite) TestSimulateRevoke() { a := banktypes.NewSendAuthorization(initCoins, nil) expire := time.Now().Add(30 * time.Hour) - err = suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) suite.Require().NoError(err) // execute operation @@ -187,9 +175,6 @@ func (suite *SimTestSuite) TestSimulateExec() { s := rand.NewSource(1) r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) - suite.Require().NoError(err) initAmt := sdk.TokensFromConsensusPower(200000, sdk.DefaultPowerReduction) initCoins := sdk.NewCoins(sdk.NewCoin("stake", initAmt)) @@ -198,7 +183,7 @@ func (suite *SimTestSuite) TestSimulateExec() { a := banktypes.NewSendAuthorization(initCoins, nil) expire := suite.ctx.HeaderInfo().Time.Add(1 * time.Hour) - err = suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) suite.Require().NoError(err) // execute operation diff --git a/x/bank/keeper/collections_test.go b/x/bank/keeper/collections_test.go index 15c22c489d06..1261e083268f 100644 --- a/x/bank/keeper/collections_test.go +++ b/x/bank/keeper/collections_test.go @@ -2,13 +2,13 @@ package keeper_test import ( "testing" + "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "cosmossdk.io/collections" + "cosmossdk.io/core/header" "cosmossdk.io/log" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -27,7 +27,7 @@ import ( func TestBankStateCompatibility(t *testing.T) { key := storetypes.NewKVStoreKey(banktypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) encCfg := moduletestutil.MakeTestEncodingConfig() storeService := runtime.NewKVStoreService(key) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 0bac7d33ee31..22b969a2c87e 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -11,8 +11,6 @@ import ( "time" abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" @@ -130,7 +128,7 @@ func TestKeeperTestSuite(t *testing.T) { func (suite *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(banktypes.StoreKey) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) encCfg := moduletestutil.MakeTestEncodingConfig() storeService := runtime.NewKVStoreService(key) @@ -1209,7 +1207,7 @@ func (suite *KeeperTestSuite) TestSendCoinsWithRestrictions() { func (suite *KeeperTestSuite) TestSendCoins_Invalid_SendLockedCoins() { balances := sdk.NewCoins(newFooCoin(50)) - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -1231,7 +1229,7 @@ func (suite *KeeperTestSuite) TestSendCoins_Invalid_NoSpendableCoins() { coins := sdk.NewCoins(coin) balances := coins - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := coins @@ -1255,7 +1253,7 @@ func (suite *KeeperTestSuite) TestSendCoins_Invalid_NoSpendableCoins() { func (suite *KeeperTestSuite) TestValidateBalance() { ctx := suite.ctx require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) @@ -1453,7 +1451,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { func (suite *KeeperTestSuite) TestSpendableCoins() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -1461,7 +1459,7 @@ func (suite *KeeperTestSuite) TestSpendableCoins() { acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) - vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) + vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, now.Unix(), endTime.Unix()) suite.Require().NoError(err) suite.mockFundAccount(accAddrs[0]) @@ -1487,7 +1485,7 @@ func (suite *KeeperTestSuite) TestSpendableCoins() { func (suite *KeeperTestSuite) TestVestingAccountSend() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -1517,7 +1515,7 @@ func (suite *KeeperTestSuite) TestVestingAccountSend() { func (suite *KeeperTestSuite) TestPeriodicVestingAccountSend() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) @@ -1528,7 +1526,7 @@ func (suite *KeeperTestSuite) TestPeriodicVestingAccountSend() { } acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) - vacc, err := vesting.NewPeriodicVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), periods) + vacc, err := vesting.NewPeriodicVestingAccount(acc0, origCoins, now.Unix(), periods) suite.Require().NoError(err) suite.mockFundAccount(accAddrs[0]) @@ -1552,7 +1550,7 @@ func (suite *KeeperTestSuite) TestPeriodicVestingAccountSend() { func (suite *KeeperTestSuite) TestVestingAccountReceive() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -1560,7 +1558,7 @@ func (suite *KeeperTestSuite) TestVestingAccountReceive() { acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) - vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) + vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, now.Unix(), endTime.Unix()) suite.Require().NoError(err) suite.mockFundAccount(accAddrs[0]) @@ -1585,7 +1583,7 @@ func (suite *KeeperTestSuite) TestVestingAccountReceive() { func (suite *KeeperTestSuite) TestPeriodicVestingAccountReceive() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) @@ -1598,7 +1596,7 @@ func (suite *KeeperTestSuite) TestPeriodicVestingAccountReceive() { vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, } - vacc, err := vesting.NewPeriodicVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), periods) + vacc, err := vesting.NewPeriodicVestingAccount(acc0, origCoins, now.Unix(), periods) suite.Require().NoError(err) suite.mockFundAccount(accAddrs[0]) @@ -1623,7 +1621,7 @@ func (suite *KeeperTestSuite) TestPeriodicVestingAccountReceive() { func (suite *KeeperTestSuite) TestDelegateCoins() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -1631,7 +1629,7 @@ func (suite *KeeperTestSuite) TestDelegateCoins() { acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) - vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) + vacc, err := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.HeaderInfo().Time.Unix(), endTime.Unix()) suite.Require().NoError(err) suite.mockFundAccount(accAddrs[0]) @@ -1681,7 +1679,7 @@ func (suite *KeeperTestSuite) TestDelegateCoins_Invalid() { func (suite *KeeperTestSuite) TestUndelegateCoins() { ctx := sdk.UnwrapSDKContext(suite.ctx) require := suite.Require() - now := cmttime.Now() + now := time.Now() endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 60bfac85845f..2bbbd9749eb3 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -174,7 +174,7 @@ func sendMsgSend( return err } - _, _, err = app.SimTxFinalizeBlock(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return err } @@ -390,7 +390,7 @@ func sendMsgMultiSend( if err != nil { return err } - _, _, err = app.SimTxFinalizeBlock(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return err } diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 5bb0e0c5da2e..e32c39c53846 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -4,7 +4,6 @@ import ( "math/rand" "testing" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -104,12 +103,6 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgSend(suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -134,12 +127,6 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgMultiSend(suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -170,13 +157,6 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, accCount) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }, - ) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgSendToModuleAccount(suite.txConfig, suite.accountKeeper, suite.bankKeeper, moduleAccCount) @@ -205,12 +185,6 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() { r := rand.New(s) accounts := suite.getTestingAccounts(r, accCount) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgMultiSendToModuleAccount(suite.txConfig, suite.accountKeeper, suite.bankKeeper, mAccCount) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 1ca99d628fdd..4043919c7ea8 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -4,12 +4,12 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "cosmossdk.io/collections" "cosmossdk.io/core/comet" + "cosmossdk.io/core/header" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/distribution" @@ -32,7 +32,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: time.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -91,7 +91,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: time.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -221,7 +221,7 @@ func TestAllocateTokensTruncation(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: time.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index e004d36ca2e5..8a17df9eaa94 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -3,11 +3,11 @@ package keeper_test import ( "testing" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "cosmossdk.io/collections" + "cosmossdk.io/core/header" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/distribution" @@ -30,7 +30,7 @@ func TestCalculateRewardsBasic(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -132,7 +132,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -237,7 +237,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -363,7 +363,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -462,7 +462,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -539,7 +539,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -657,7 +657,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -796,7 +796,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) @@ -997,7 +997,7 @@ func Test100PercentCommissionReward(t *testing.T) { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 388d958e975a..30fdc8d0515d 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/distribution" @@ -39,7 +39,7 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) - ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: time.Now()}) + ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) addrs := simtestutil.CreateIncrementalAccounts(2) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 808aef156750..8799ff1cdf54 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -4,7 +4,6 @@ import ( "math/rand" "testing" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -74,11 +73,6 @@ func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) // execute operation op := simulation.SimulateMsgSetWithdrawAddress(suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.distrKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -119,12 +113,6 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() { suite.setupValidatorRewards(valBz) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgWithdrawDelegatorReward(suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.distrKeeper, suite.stakingKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -186,11 +174,6 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName suite.Require().NoError(suite.distrKeeper.ValidatorsAccumulatedCommission.Set(suite.ctx, val0, types.ValidatorAccumulatedCommission{Commission: valCommission})) suite.Require().NoError(suite.distrKeeper.ValidatorsAccumulatedCommission.Set(suite.ctx, genVal0, types.ValidatorAccumulatedCommission{Commission: valCommission})) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) // execute operation op := simulation.SimulateMsgWithdrawValidatorCommission(suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.distrKeeper, suite.stakingKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index 600f61cad7d1..2a1c542166d5 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -40,7 +39,7 @@ func (suite *GenesisTestSuite) SetupTest() { &evidenceKeeper) require.NoError(suite.T(), err) - suite.ctx = app.BaseApp.NewContextLegacy(false, cmtproto.Header{Height: 1}) + suite.ctx = app.BaseApp.NewContext(false) suite.keeper = evidenceKeeper } diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 7e10dba12722..714472e6eeca 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -6,11 +6,11 @@ import ( "fmt" "time" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" "cosmossdk.io/collections" + "cosmossdk.io/core/header" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/evidence" "cosmossdk.io/x/evidence/exported" @@ -113,7 +113,7 @@ func (suite *KeeperTestSuite) SetupTest() { router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper)) evidenceKeeper.SetRouter(router) - suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Height: 1}) + suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) suite.encCfg = moduletestutil.MakeTestEncodingConfig(evidence.AppModuleBasic{}) suite.accountKeeper = accountKeeper diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index bb5fd959e8d6..72b2196d75d7 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -78,7 +76,7 @@ func (suite *SimTestSuite) SetupTest() { ) suite.Require().NoError(err) - suite.ctx = suite.app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()}) + suite.ctx = suite.app.BaseApp.NewContext(false).WithHeaderInfo(header.Info{Time: time.Now()}) } func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { @@ -152,10 +150,6 @@ func (suite *SimTestSuite) TestSimulateMsgGrantAllowance() { addr2, err := suite.accountKeeper.AddressCodec().BytesToString(accounts[2].Address) require.NoError(err) - // new block - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - require.NoError(err) - // execute operation op := simulation.SimulateMsgGrantAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) operationMsg, futureOperations, err := op(r, app.BaseApp, ctx.WithHeaderInfo(header.Info{Time: time.Now()}), accounts, "") @@ -178,16 +172,13 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeAllowance() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - // begin a new block - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) - require.NoError(err) feeAmt := sdk.TokensFromConsensusPower(200000, sdk.DefaultPowerReduction) feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) granter, grantee := accounts[0], accounts[1] oneYear := ctx.HeaderInfo().Time.AddDate(1, 0, 0) - err = suite.feegrantKeeper.GrantAllowance( + err := suite.feegrantKeeper.GrantAllowance( ctx, granter.Address, grantee.Address, diff --git a/x/genutil/types/genesis.go b/x/genutil/types/genesis.go index 3c322fa086fd..b5b335ca1337 100644 --- a/x/genutil/types/genesis.go +++ b/x/genutil/types/genesis.go @@ -14,7 +14,6 @@ import ( cmtjson "github.com/cometbft/cometbft/libs/json" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/cosmos/cosmos-sdk/version" ) @@ -68,7 +67,7 @@ func (ag *AppGenesis) ValidateAndComplete() error { } if ag.GenesisTime.IsZero() { - ag.GenesisTime = cmttime.Now() + ag.GenesisTime = time.Now().Round(0).UTC() } if err := ag.Consensus.ValidateAndComplete(); err != nil { diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index f1bb48e0bfdc..cfa8c5adabc0 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/require" "cosmossdk.io/collections" @@ -87,11 +86,6 @@ func TestTickExpiredDepositPeriod(t *testing.T) { ctx := app.BaseApp.NewContext(false) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) @@ -137,12 +131,6 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { app := suite.App ctx := app.BaseApp.NewContext(false) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) @@ -208,12 +196,6 @@ func TestTickPassedDepositPeriod(t *testing.T) { app := suite.App ctx := app.BaseApp.NewContext(false) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) newProposalMsg, err := v1.NewMsgSubmitProposal( @@ -273,12 +255,6 @@ func TestTickPassedVotingPeriod(t *testing.T) { addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens.Mul(math.NewInt(depositMultiplier))) SortAddresses(addrs) - - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) @@ -367,18 +343,11 @@ func TestProposalPassedEndblocker(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - valAddr := sdk.ValAddress(addrs[0]) proposer := addrs[0] createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10}) - _, err = suite.StakingKeeper.EndBlocker(ctx) + _, err := suite.StakingKeeper.EndBlocker(ctx) require.NoError(t, err) macc := suite.GovKeeper.GetGovernanceAccount(ctx) require.NotNil(t, macc) @@ -428,17 +397,11 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - valAddr := sdk.ValAddress(addrs[0]) proposer := addrs[0] createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10}) - _, err = suite.StakingKeeper.EndBlocker(ctx) + _, err := suite.StakingKeeper.EndBlocker(ctx) require.NoError(t, err) msg := banktypes.NewMsgSend(authtypes.NewModuleAddress(types.ModuleName), addrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000)))) proposal, err := suite.GovKeeper.SubmitProposal(ctx, []sdk.Msg{msg}, "", "title", "summary", proposer, false) @@ -512,13 +475,6 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - valAddr := sdk.ValAddress(addrs[0]) proposer := addrs[0] diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index cb22362168e8..9421dcba2a9b 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" @@ -142,12 +141,6 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { r := rand.New(s) accounts := getTestingAccounts(t, r, suite.AccountKeeper, suite.BankKeeper, suite.StakingKeeper, ctx, 3) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgSubmitProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.MsgSimulatorFn()) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") @@ -174,12 +167,6 @@ func TestSimulateMsgSubmitLegacyProposal(t *testing.T) { r := rand.New(s) accounts := getTestingAccounts(t, r, suite.AccountKeeper, suite.BankKeeper, suite.StakingKeeper, ctx, 3) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgSubmitLegacyProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.ContentSimulatorFn()) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") @@ -234,12 +221,6 @@ func TestSimulateMsgCancelProposal(t *testing.T) { err = suite.GovKeeper.SetProposal(ctx, proposal) require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgCancelProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") @@ -283,12 +264,6 @@ func TestSimulateMsgDeposit(t *testing.T) { err = suite.GovKeeper.SetProposal(ctx, proposal) require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgDeposit(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") @@ -333,12 +308,6 @@ func TestSimulateMsgVote(t *testing.T) { err = suite.GovKeeper.ActivateVotingPeriod(ctx, proposal) require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgVote(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") @@ -381,12 +350,6 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { err = suite.GovKeeper.ActivateVotingPeriod(ctx, proposal) require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgVoteWeighted(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 98ef2f089294..488537aa002d 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" @@ -48,7 +47,7 @@ type TestSuite struct { } func (s *TestSuite) SetupTest() { - s.blockTime = cmttime.Now() + s.blockTime = time.Now().Round(0).UTC() key := storetypes.NewKVStoreKey(group.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) diff --git a/x/group/simulation/operations_test.go b/x/group/simulation/operations_test.go index f3b1d4ad2c8b..8038b1d0fa88 100644 --- a/x/group/simulation/operations_test.go +++ b/x/group/simulation/operations_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -130,12 +129,6 @@ func (suite *SimTestSuite) TestSimulateCreateGroup() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 1) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - acc := accounts[0] // execute operation @@ -157,12 +150,6 @@ func (suite *SimTestSuite) TestSimulateCreateGroupWithPolicy() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 1) - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - acc := accounts[0] // execute operation @@ -199,12 +186,6 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() { ) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgCreateGroupPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -250,12 +231,6 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgSubmitProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -314,12 +289,6 @@ func (suite *SimTestSuite) TestWithdrawProposal() { _, err = suite.groupKeeper.SubmitProposal(ctx, proposalReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgWithdrawProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -379,12 +348,6 @@ func (suite *SimTestSuite) TestSimulateVote() { _, err = suite.groupKeeper.SubmitProposal(ctx, proposalReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgVote(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -452,12 +415,6 @@ func (suite *SimTestSuite) TestSimulateExec() { }) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgExec(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -492,12 +449,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() { ) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -532,12 +483,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() { ) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -572,12 +517,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() { ) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupMembers(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -623,12 +562,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupPolicyAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -674,12 +607,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupPolicyDecisionPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -725,12 +652,6 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) - // execute operation op := simulation.SimulateMsgUpdateGroupPolicyMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") @@ -789,12 +710,6 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() { _, err = suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) require.NoError(err) - _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - require.NoError(err) - // execute operation op := simulation.SimulateMsgLeaveGroup(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.groupKeeper, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") diff --git a/x/nft/go.mod b/x/nft/go.mod index 4a2371d67d8e..d16106c29148 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -11,7 +11,6 @@ require ( cosmossdk.io/math v1.1.3-rc.1 cosmossdk.io/store v1.0.0-rc.0 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 - github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.11 @@ -41,6 +40,7 @@ require ( github.com/cockroachdb/pebble v0.0.0-20230824192853-9bb0864bdb98 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft v0.38.0 // indirect github.com/cometbft/cometbft-db v0.8.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.0.0 // indirect diff --git a/x/nft/simulation/operations_test.go b/x/nft/simulation/operations_test.go index d4205558034c..6d7a8d374d4a 100644 --- a/x/nft/simulation/operations_test.go +++ b/x/nft/simulation/operations_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -125,12 +124,6 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { blockTime := time.Now().UTC() ctx := suite.ctx.WithHeaderInfo(header.Info{Time: blockTime}) - // begin new block - _, err := suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.app.LastBlockHeight() + 1, - Hash: suite.app.LastCommitID().Hash, - }) - suite.Require().NoError(err) // execute operation registry := suite.interfaceRegistry op := simulation.SimulateMsgSend(codec.NewProtoCodec(registry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.nftKeeper) diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index e3ddac6e1c2a..5b85d9be80f2 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -11,7 +11,6 @@ require ( cosmossdk.io/x/distribution v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 - github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.11 @@ -45,6 +44,7 @@ require ( github.com/cockroachdb/pebble v0.0.0-20230824192853-9bb0864bdb98 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft v0.38.0 // indirect github.com/cometbft/cometbft-db v0.8.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.0.0 // indirect diff --git a/x/protocolpool/simulation/operations_test.go b/x/protocolpool/simulation/operations_test.go index b22ff8a60cb3..647e2bb9f406 100644 --- a/x/protocolpool/simulation/operations_test.go +++ b/x/protocolpool/simulation/operations_test.go @@ -4,7 +4,6 @@ import ( "math/rand" "testing" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" @@ -113,12 +112,6 @@ func TestSimulateMsgFundCommunityPool(t *testing.T) { r := rand.New(s) accounts := getTestingAccounts(t, r, suite.AccountKeeper, suite.BankKeeper, suite.StakingKeeper, suite.Ctx, 3) - _, err := suite.App.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: suite.App.LastBlockHeight() + 1, - Hash: suite.App.LastCommitID().Hash, - }) - require.NoError(t, err) - // execute operation op := simulation.SimulateMsgFundCommunityPool(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.PoolKeeper) operationMsg, futureOperations, err := op(r, suite.App.BaseApp, suite.Ctx, accounts, "") diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index cb18943a66c5..502255de1f42 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -4,10 +4,9 @@ import ( "errors" "testing" - abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/math" @@ -91,14 +90,12 @@ func TestSlashingMsgs(t *testing.T) { ) require.NoError(t, err) - header := cmtproto.Header{Height: app.LastBlockHeight() + 1} + headerInfo := header.Info{Height: app.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) + _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) ctxCheck = baseApp.NewContext(true) validator, err := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) require.NoError(t, err) @@ -113,8 +110,8 @@ func TestSlashingMsgs(t *testing.T) { require.NoError(t, err) // unjail should fail with unknown validator - header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) + headerInfo = header.Info{Height: app.LastBlockHeight() + 1} + _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) require.Error(t, err) require.True(t, errors.Is(types.ErrValidatorNotJailed, err)) } diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index 23c03a6da8a1..7b75339ef13e 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -187,6 +187,7 @@ func (suite *SimTestSuite) TestSimulateMsgUnjail() { // begin a new block _, err = suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, Time: blockTime}) suite.Require().NoError(err) + // execute operation op := simulation.SimulateMsgUnjail(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) operationMsg, futureOperations, err := op(suite.r, suite.app.BaseApp, ctx, suite.accounts, "") diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 600dbc8eae0f..921648d7c501 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -3,11 +3,10 @@ package staking_test import ( "testing" - abci "github.com/cometbft/cometbft/abci/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" "cosmossdk.io/collections" + "cosmossdk.io/core/header" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/math" @@ -74,14 +73,12 @@ func TestStakingMsgs(t *testing.T) { ) require.NoError(t, err) - header := cmtproto.Header{Height: app.LastBlockHeight() + 1} + headerInfo := header.Info{Height: app.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) + _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) ctxCheck = app.BaseApp.NewContext(true) validator, err := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) require.NoError(t, err) @@ -90,15 +87,12 @@ func TestStakingMsgs(t *testing.T) { require.Equal(t, types.Bonded, validator.Status) require.True(math.IntEq(t, bondTokens, validator.BondedTokens())) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) - // edit the validator description = types.NewDescription("bar_moniker", "", "", "", "") editValidatorMsg := types.NewMsgEditValidator(sdk.ValAddress(addr1).String(), description, nil, nil) - header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1) + headerInfo = header.Info{Height: app.LastBlockHeight() + 1} + _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1) require.NoError(t, err) ctxCheck = app.BaseApp.NewContext(true) @@ -110,8 +104,8 @@ func TestStakingMsgs(t *testing.T) { require.True(t, sdk.Coins{genCoin}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr2))) delegateMsg := types.NewMsgDelegate(addr2.String(), sdk.ValAddress(addr1).String(), bondCoin) - header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2) + headerInfo = header.Info{Height: app.LastBlockHeight() + 1} + _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2) require.NoError(t, err) ctxCheck = app.BaseApp.NewContext(true) @@ -121,8 +115,8 @@ func TestStakingMsgs(t *testing.T) { // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2.String(), sdk.ValAddress(addr1).String(), bondCoin) - header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2) + headerInfo = header.Info{Height: app.LastBlockHeight() + 1} + _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2) require.NoError(t, err) // delegation should exist anymore