From d601421982e56ae0fbd0e35dda0a15709a3d213c Mon Sep 17 00:00:00 2001 From: Prathyusha Lakkireddy Date: Tue, 14 Sep 2021 20:13:12 +0530 Subject: [PATCH] chore: change the inconsistent error message in DecCoin.ParseDecCoin func (#9831) ## Description Closes: #9791 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- types/dec_coin.go | 2 +- types/dec_coin_test.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/types/dec_coin.go b/types/dec_coin.go index 6e400d7a05..74a5a1ae44 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -628,7 +628,7 @@ func ParseDecCoin(coinStr string) (coin DecCoin, err error) { } if err := ValidateDenom(denomStr); err != nil { - return DecCoin{}, fmt.Errorf("invalid denom cannot contain upper case characters or spaces: %s", err) + return DecCoin{}, fmt.Errorf("invalid denom cannot contain spaces: %s", err) } return NewDecCoinFromDec(denomStr, amount), nil diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index c0cf44cd60..2f35075d3c 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -671,7 +671,7 @@ func (s *decCoinTestSuite) TestDecCoins_IsAllPositive() { {"One Coin - Zero value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(0)}}, false}, - {"One Coin - Postive value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(5)}}, true}, + {"One Coin - Positive value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(5)}}, true}, {"One Coin - Negative value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(-15)}}, false}, @@ -789,7 +789,7 @@ func (s *decCoinTestSuite) TestDecCoins_IsZero() { {"One Coin - Zero value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(0)}}, true}, - {"One Coin - Postive value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(5)}}, false}, + {"One Coin - Positive value", sdk.DecCoins{sdk.DecCoin{testDenom1, sdk.NewDec(5)}}, false}, {"Multiple Coins - All zero value", sdk.DecCoins{ sdk.DecCoin{testDenom1, sdk.NewDec(0)}, @@ -1084,7 +1084,7 @@ func (s *decCoinTestSuite) TestDecCoin_Validate() { input sdk.DecCoin expectedPass bool }{ - {"Uninitalized deccoin", empty, false}, + {"Uninitialized deccoin", empty, false}, {"Invalid denom string", sdk.DecCoin{"(){9**&})", sdk.NewDec(33)}, false}, @@ -1121,11 +1121,9 @@ func (s *decCoinTestSuite) TestDecCoin_ParseDecCoin() { {"Precision over limit", "9.11111111111111111111stake", empty, true}, - // TODO - Clarify - According to error message for ValidateDenom call, supposed to - // throw error when upper case characters are used. Currently uppercase denoms are allowed. - {"Invalid denom", "9.3STAKE", sdk.DecCoin{"STAKE", sdk.NewDecWithPrec(93, 1)}, false}, + {"Valid upper case denom", "9.3STAKE", sdk.DecCoin{"STAKE", sdk.NewDecWithPrec(93, 1)}, false}, - {"Valid input - amount and denom seperated by space", "9.3 stake", sdk.DecCoin{"stake", sdk.NewDecWithPrec(93, 1)}, false}, + {"Valid input - amount and denom separated by space", "9.3 stake", sdk.DecCoin{"stake", sdk.NewDecWithPrec(93, 1)}, false}, {"Valid input - amount and denom concatenated", "9.3stake", sdk.DecCoin{"stake", sdk.NewDecWithPrec(93, 1)}, false}, }