Skip to content

Commit

Permalink
fix(go): do not delete deposit authz when remaining limit is 0 (#162)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored May 1, 2024
1 parent b978069 commit bee24ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func (m DepositDeploymentAuthorization) Accept(_ sdk.Context, msg sdk.Msg) (auth
return authz.AcceptResponse{}, sdkerrors.ErrInsufficientFunds.Wrapf("requested amount is more than spend limit")
}
limitLeft := m.SpendLimit.Sub(mDepositDeployment.Amount)
if limitLeft.IsZero() {
return authz.AcceptResponse{Accept: true, Delete: true}, nil
}

return authz.AcceptResponse{Accept: true, Delete: false, Updated: &DepositDeploymentAuthorization{SpendLimit: limitLeft}}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions go/node/deployment/v1beta3/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ func TestDepositDeploymentAuthorization_Accept(t *testing.T) {
dda, ok = response.Updated.(*types.DepositDeploymentAuthorization)
require.True(t, ok)

// Deposit the limit (now 1), expect that it is deleted
// Deposit the limit (now 1), expect that it is not to be deleted
msg = types.NewMsgDepositDeployment(testutil.DeploymentID(t), sdk.NewInt64Coin(tutil.CoinDenom, 1), testutil.AccAddress(t).String())
response, err = dda.Accept(sdk.Context{}, msg)
require.NoError(t, err)
require.True(t, response.Accept)
require.True(t, response.Delete)
require.False(t, response.Delete)
}

0 comments on commit bee24ca

Please sign in to comment.