Skip to content

Commit

Permalink
Merge pull request #559 from Pylons-tech/fix/zero-royalty
Browse files Browse the repository at this point in the history
fix: zero royalty issue was resolved
  • Loading branch information
MikeSofaer authored Apr 20, 2022
2 parents 013263c + cfca4c7 commit 89479b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x/pylons/types/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func ValidateItemOutputs(io []ItemOutput, idMap map[string]bool) error {

// item.TradePercentage must be in (0, 1)
if !item.TradePercentage.IsNil() {
if item.TradePercentage.LTE(sdk.ZeroDec()) || item.TradePercentage.GTE(sdk.OneDec()) {
if item.TradePercentage.LT(sdk.ZeroDec()) || item.TradePercentage.GTE(sdk.OneDec()) {
return sdkerrors.Wrapf(ErrInvalidRequestField, "invalid trade percentage on itemOutput %s", item.ID)
}
}
Expand Down
3 changes: 3 additions & 0 deletions x/pylons/types/recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,11 @@ func TestValidateItemOutputs(t *testing.T) {
}{
{desc: "ValidEmpty", obj: "[]"},
{desc: "ValidSingle", obj: "[{\"ID\": \"test1\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test1\"}], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]"},
{desc: "ValidSingle1", obj: "[{\"ID\": \"test1\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test1\"}], \"mutableStrings\": [],\"tradePercentage\": \"0\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]"},
{desc: "ValidMultiple", obj: "[{\"ID\": \"test1\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test1\"}], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}, {\"ID\": \"test2\", \"doubles\": [], \"longs\": [{\"key\": \"test2\", \"lower\": 1, \"upper\": 2}], \"strings\": [], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]"},
{desc: "InvalidSingle1", obj: "[{\"ID\": \"test\", \"doubles\": [], \"longs\": [], \"strings\": [], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": [{\"denom\": \"\", \"amount\": \"\"}]}]", err: ErrInvalidRequestField},
{desc: "InvalidtradePercentage", obj: "[{\"ID\": \"test1\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test1\"}], \"mutableStrings\": [],\"tradePercentage\": \"-1\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]", err: ErrInvalidRequestField},
{desc: "InvalidtradePercentage1", obj: "[{\"ID\": \"test1\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test1\"}], \"mutableStrings\": [],\"tradePercentage\": \"1\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]", err: ErrInvalidRequestField},
{desc: "InValidMultiple", obj: "[{\"ID\": \"test\", \"doubles\": [], \"longs\": [], \"strings\": [{\"key\": \"test\"}], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": {\"denom\": \"\", \"amount\": \"\"}}, {\"ID\": \"test\", \"doubles\": [], \"longs\": [{\"key\": \"test\", \"lower\": 1, \"upper\": 2}], \"strings\": [], \"mutableStrings\": [],\"tradePercentage\": \"0.01\", \"transferFee\": [{\"denom\": \"pylons\", \"amount\": \"0.01\"}]}]", err: ErrInvalidRequestField},
} {
tc := tc
Expand Down

0 comments on commit 89479b9

Please sign in to comment.