Fix is_valid bug (#3211)
This commit is contained in:
parent
4a65bda1f5
commit
d3804774d4
|
@ -140,10 +140,8 @@ 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() {
|
||||
// Check single coin case
|
||||
if !(Coins{coins[0]}).IsValid() {
|
||||
return false
|
||||
}
|
||||
lowDenom := coins[0].Denom
|
||||
|
|
|
@ -251,8 +251,13 @@ func TestMinusCoins(t *testing.T) {
|
|||
|
||||
func TestCoins(t *testing.T) {
|
||||
good := Coins{
|
||||
{"GAS", NewInt(1)},
|
||||
{"MINERAL", NewInt(1)},
|
||||
{"gas", NewInt(1)},
|
||||
{"mineral", NewInt(1)},
|
||||
{"tree", NewInt(1)},
|
||||
}
|
||||
mixedCase1 := Coins{
|
||||
{"gAs", NewInt(1)},
|
||||
{"MineraL", NewInt(1)},
|
||||
{"TREE", NewInt(1)},
|
||||
}
|
||||
empty := Coins{
|
||||
|
@ -287,6 +292,7 @@ func TestCoins(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.True(t, good.IsValid(), "Coins are valid")
|
||||
assert.False(t, mixedCase1.IsValid(), "Coins denoms contain upper case characters")
|
||||
assert.True(t, good.IsPositive(), "Expected coins to be positive: %v", good)
|
||||
assert.False(t, null.IsPositive(), "Expected coins to not be positive: %v", null)
|
||||
assert.True(t, good.IsAllGTE(empty), "Expected %v to be >= %v", good, empty)
|
||||
|
|
Loading…
Reference in New Issue