Skip to content

Commit

Permalink
called Endblocker in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Oct 6, 2018
1 parent 92770ee commit 668cfef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/stake/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
}

// Called every block, process inflation, update validator set
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (ValidatorUpdates []abci.Validator) {
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (ValidatorUpdates []abci.ValidatorUpdate) {
endBlockerTags := sdk.EmptyTags()

matureUnbonds := k.DequeueAllMatureUnbondingQueue(ctx, ctx.BlockHeader().Time)
Expand Down
7 changes: 6 additions & 1 deletion x/stake/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,20 @@ func TestUnbondingPeriod(t *testing.T) {
got := handleMsgCreateValidator(ctx, msgCreateValidator, keeper)
require.True(t, got.IsOK(), "expected no error on runMsgCreateValidator")

EndBlocker(ctx, keeper)

// begin unbonding
msgBeginUnbonding := NewMsgBeginUnbonding(sdk.AccAddress(validatorAddr), validatorAddr, sdk.NewDec(10))
got = handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper)
require.True(t, got.IsOK(), "expected no error")
origHeader := ctx.BlockHeader()

_, found := keeper.GetUnbondingDelegation(ctx, sdk.AccAddress(validatorAddr), validatorAddr)
require.True(t, found, "should not have unbonded")

// cannot complete unbonding at same time
EndBlocker(ctx, keeper)
_, found := keeper.GetUnbondingDelegation(ctx, sdk.AccAddress(validatorAddr), validatorAddr)
_, found = keeper.GetUnbondingDelegation(ctx, sdk.AccAddress(validatorAddr), validatorAddr)
require.True(t, found, "should not have unbonded")

// cannot complete unbonding at time 6 seconds later
Expand Down

0 comments on commit 668cfef

Please sign in to comment.