Fixed Coins IsValid, issue #8
This commit is contained in:
parent
6e3a199f09
commit
2f7875dec0
|
@ -35,6 +35,8 @@ func (coins Coins) IsValid() bool {
|
|||
if coin.Amount == 0 {
|
||||
return false
|
||||
}
|
||||
// we compare each coin against the last denom
|
||||
lowDenom = coin.Denom
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -42,6 +42,19 @@ func TestCoinsBadSort(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCoinsBadSort2(t *testing.T) {
|
||||
// both are after the first one, but the second and third are in the wrong order
|
||||
coins := Coins{
|
||||
Coin{"GAS", 1},
|
||||
Coin{"TREE", 1},
|
||||
Coin{"MINERAL", 1},
|
||||
}
|
||||
|
||||
if coins.IsValid() {
|
||||
t.Fatal("Coins are not sorted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoinsBadAmount(t *testing.T) {
|
||||
coins := Coins{
|
||||
Coin{"GAS", 1},
|
||||
|
|
Loading…
Reference in New Issue