Unverified Commit 28d9cfbf authored by Roman's avatar Roman Committed by GitHub
Browse files

refactor: begin unlock event with uses split lock (#2996)

parent 4fed7db0
Showing with 10 additions and 11 deletions
+10 -11
......@@ -235,6 +235,10 @@ func (k Keeper) beginUnlock(ctx sdk.Context, lock types.PeriodLock, coins sdk.Co
k.hooks.OnStartUnlock(ctx, lock.OwnerAddress(), lock.ID, lock.Coins, lock.Duration, lock.EndTime)
}
ctx.EventManager().EmitEvents(sdk.Events{
createBeginUnlockEvent(&lock),
})
return nil
}
......
......@@ -96,14 +96,7 @@ func (server msgServer) BeginUnlocking(goCtx context.Context, msg *types.MsgBegi
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
lock, err = server.keeper.GetLockByID(ctx, msg.ID)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
ctx.EventManager().EmitEvents(sdk.Events{
createBeginUnlockEvent(lock),
})
// N.B. begin unlock event is emitted downstream in the keeper method.
return &types.MsgBeginUnlockingResponse{}, nil
}
......
......@@ -172,8 +172,8 @@ func (suite *KeeperTestSuite) TestMsgBeginUnlocking() {
suite.FundAcc(test.param.lockOwner, test.param.coinsInOwnerAddress)
msgServer := keeper.NewMsgServerImpl(suite.App.LockupKeeper)
c := sdk.WrapSDKContext(suite.Ctx)
resp, err := msgServer.LockTokens(c, types.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock))
goCtx := sdk.WrapSDKContext(suite.Ctx)
resp, err := msgServer.LockTokens(goCtx, types.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock))
suite.Require().NoError(err)
if test.param.isSyntheticLockup {
......@@ -181,12 +181,14 @@ func (suite *KeeperTestSuite) TestMsgBeginUnlocking() {
suite.Require().NoError(err)
}
_, err = msgServer.BeginUnlocking(c, types.NewMsgBeginUnlocking(test.param.lockOwner, resp.ID, test.param.coinsToUnlock))
_, err = msgServer.BeginUnlocking(goCtx, types.NewMsgBeginUnlocking(test.param.lockOwner, resp.ID, test.param.coinsToUnlock))
if test.expectPass {
suite.Require().NoError(err)
suite.AssertEventEmitted(suite.Ctx, types.TypeEvtBeginUnlock, 1)
} else {
suite.Require().Error(err)
suite.AssertEventEmitted(suite.Ctx, types.TypeEvtBeginUnlock, 0)
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment