Merge PR #3207: Fix token printing bug
* Add IsPositive, case check on coins[0] * Link to correct PR * Add testcase
This commit is contained in:
parent
0d63c92be1
commit
5ca8c5bb83
|
@ -19,6 +19,7 @@ BREAKING CHANGES
|
|||
|
||||
* SDK
|
||||
* [\#3064](https://github.com/cosmos/cosmos-sdk/issues/3064) Sanitize `sdk.Coin` denom. Coins denoms are now case insensitive, i.e. 100fooToken equals to 100FOOTOKEN.
|
||||
* \#3207 - Fix token printing bug
|
||||
|
||||
* Tendermint
|
||||
|
||||
|
|
|
@ -144,8 +144,13 @@ func (coins Coins) IsValid() bool {
|
|||
case 1:
|
||||
return coins[0].IsPositive()
|
||||
default:
|
||||
if strings.ToLower(coins[0].Denom) != coins[0].Denom {
|
||||
return false
|
||||
}
|
||||
if !coins[0].IsPositive() {
|
||||
return false
|
||||
}
|
||||
lowDenom := coins[0].Denom
|
||||
|
||||
for _, coin := range coins[1:] {
|
||||
if strings.ToLower(coin.Denom) != coin.Denom {
|
||||
return false
|
||||
|
|
|
@ -286,6 +286,10 @@ func TestCoins(t *testing.T) {
|
|||
{"gas", NewInt(1)},
|
||||
{"mineral", NewInt(1)},
|
||||
}
|
||||
neg := Coins{
|
||||
{"gas", NewInt(-1)},
|
||||
{"mineral", NewInt(1)},
|
||||
}
|
||||
|
||||
assert.True(t, good.IsValid(), "Coins are valid")
|
||||
assert.False(t, mixedCase.IsValid(), "Coins denoms contain upper case characters")
|
||||
|
@ -298,6 +302,7 @@ func TestCoins(t *testing.T) {
|
|||
assert.False(t, badSort2.IsValid(), "Coins are not sorted")
|
||||
assert.False(t, badAmt.IsValid(), "Coins cannot include 0 amounts")
|
||||
assert.False(t, dup.IsValid(), "Duplicate coin")
|
||||
assert.False(t, neg.IsValid(), "Negative first-denom coin")
|
||||
}
|
||||
|
||||
func TestCoinsGT(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue