chore: check if fund exists for CancelContinuousFund in x/protocolpool (#24560)
This commit is contained in:
parent
018f9e1a1d
commit
a21b5ef111
@ -146,6 +146,15 @@ func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCance
|
||||
canceledHeight := sdkCtx.BlockHeight()
|
||||
canceledTime := sdkCtx.BlockTime()
|
||||
|
||||
has, err := k.ContinuousFunds.Has(sdkCtx, recipient)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get continuous fund for recipient %w", err)
|
||||
}
|
||||
|
||||
if !has {
|
||||
return nil, fmt.Errorf("cannot cancel continuous fund for recipient %s - does not exist", msg.Recipient)
|
||||
}
|
||||
|
||||
if err := k.ContinuousFunds.Remove(sdkCtx, recipient); err != nil {
|
||||
return nil, fmt.Errorf("failed to remove continuous fund for recipient %s: %w", msg.Recipient, err)
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() {
|
||||
expErrMsg: "decoding bech32 failed:",
|
||||
},
|
||||
{
|
||||
name: "remove a continuous fund that already was removed - no error",
|
||||
name: "remove a continuous fund that already was removed - error does not exist",
|
||||
msg: &types.MsgCancelContinuousFund{
|
||||
Authority: validAuthority,
|
||||
Recipient: validRecipient.String(),
|
||||
@ -377,7 +377,7 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() {
|
||||
// Ensure the continuous fund is not set so that Remove fails.
|
||||
_ = suite.poolKeeper.ContinuousFunds.Remove(suite.ctx, validRecipient)
|
||||
},
|
||||
expErr: false,
|
||||
expErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid cancel continuous fund",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user