Merge pull request from GHSA-86h5-xcpx-cfqc
* check undelegation after redelegation * add comment * using app v1 * set up test * update test * Update x/staking/keeper/slash.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * use switch inside slashing logic * update slash redelegation test --------- Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
Hieu Vu
Julien Robert
parent
f44d9784e7
commit
8585d538f1
@@ -17,11 +17,13 @@ import (
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
stakingtypes "cosmossdk.io/x/staking/types"
|
||||
|
||||
coreheader "cosmossdk.io/core/header"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/mock"
|
||||
@@ -107,6 +109,35 @@ func SetupAtGenesis(appConfig depinject.Config, extraOutputs ...interface{}) (*r
|
||||
return SetupWithConfiguration(appConfig, cfg, extraOutputs...)
|
||||
}
|
||||
|
||||
// NextBlock starts a new block.
|
||||
func NextBlock(app *runtime.App, ctx sdk.Context, jumpTime time.Duration) (sdk.Context, error) {
|
||||
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: ctx.BlockHeight(), Time: ctx.BlockTime()})
|
||||
if err != nil {
|
||||
return sdk.Context{}, err
|
||||
}
|
||||
_, err = app.Commit()
|
||||
if err != nil {
|
||||
return sdk.Context{}, err
|
||||
}
|
||||
|
||||
newBlockTime := ctx.BlockTime().Add(jumpTime)
|
||||
|
||||
header := ctx.BlockHeader()
|
||||
header.Time = newBlockTime
|
||||
header.Height = header.Height + 1
|
||||
|
||||
newCtx := app.BaseApp.NewUncachedContext(false, header).WithHeaderInfo(coreheader.Info{
|
||||
Height: header.Height,
|
||||
Time: header.Time,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return sdk.Context{}, err
|
||||
}
|
||||
|
||||
return newCtx, err
|
||||
}
|
||||
|
||||
// SetupWithConfiguration initializes a new runtime.App. A Nop logger is set in runtime.App.
|
||||
// appConfig defines the application configuration (f.e. app_config.go).
|
||||
// extraOutputs defines the extra outputs to be assigned by the dependency injector (depinject).
|
||||
|
||||
Reference in New Issue
Block a user