Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/ecocredit): remove fee param when amount is zero #1604

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions x/ecocredit/base/keeper/features/msg_update_class_fee.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ Feature: Msg/MsgUpdateClassFee
"fee": {}
}
"""

Scenario: the class fee is removed when amount is zero
When alice attempts to update class fee with properties
"""
{
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68",
"fee":{
"denom": "uregen",
"amount": "0"
}
}
"""
Then expect class fee with properties
"""
{
"fee": {}
}
"""
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/msg_update_class_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (k Keeper) UpdateClassFee(ctx context.Context, req *types.MsgUpdateClassFee
}

var classFee *sdkv1beta1.Coin
if req.Fee != nil {
if req.Fee != nil && req.Fee.IsPositive() {
classFee = regentypes.CoinToProtoCoin(*req.Fee)
}

Expand Down
19 changes: 19 additions & 0 deletions x/ecocredit/basket/keeper/features/msg_update_basket_fee.feature
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,22 @@ Feature: Msg/MsgUpdateBasketFee
"fee": {}
}
"""

Scenario: the basket fee is removed when amount is zero
When alice attempts to update basket fee with properties
"""
{
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68",
"fee": {
"denom": "uregen",
"amount": "0"
}
}
"""
Then expect no error
And expect basket fee with properties
"""
{
"fee": {}
}
"""
2 changes: 1 addition & 1 deletion x/ecocredit/basket/keeper/msg_update_basket_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (k Keeper) UpdateBasketFee(ctx context.Context, req *types.MsgUpdateBasketF

var basketFee *sdkv1beta1.Coin

if req.Fee != nil {
if req.Fee != nil && req.Fee.IsPositive() {
basketFee = regentypes.CoinToProtoCoin(*req.Fee)
}

Expand Down