-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
x/ecocredit/marketplace/types/v1/features/msg_set_marketplace_fees.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Feature: MsgSetMarketplaceFees | ||
|
||
Scenario: a valid message | ||
Given the message | ||
""" | ||
{ | ||
"authority": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw", | ||
"buyer_percentage_fee": "0.01", | ||
"seller_percentage_fee": "0.01", | ||
} | ||
""" | ||
When the message is validated | ||
Then expect no error | ||
|
||
Scenario: an error is returned if authority is empty | ||
Given the message | ||
""" | ||
{} | ||
""" | ||
When the message is validated | ||
Then expect the error "invalid authority address: empty address string is not allowed" | ||
|
||
Scenario: an error is returned if authority is not a valid bech32 address | ||
Given the message | ||
""" | ||
{ | ||
"authority": "foo" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "invalid authority address: decoding bech32 failed: invalid bech32 string length 3" | ||
|
||
Scenario: an error is returned if fee params is empty | ||
Given the message | ||
""" | ||
{ | ||
"authority": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "buyer_percentage_fee: non-empty value required" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v1 | ||
|
||
import "github.com/regen-network/regen-ledger/types/v2/math" | ||
|
||
// Validate performs basic validation of the FeeParams state type. | ||
func (m *FeeParams) Validate() error { | ||
_, err := math.NewPositiveDecFromString(m.BuyerPercentageFee) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = math.NewPositiveDecFromString(m.SellerPercentageFee) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |