From 2216f4716eb369073c74f0e7c5dbc98fbe9d045a Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Tue, 12 Feb 2019 10:22:04 -0500 Subject: [PATCH] Merge PR #3625: Fix Fee Comparison --- PENDING.md | 2 ++ types/coin.go | 2 +- types/coin_test.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PENDING.md b/PENDING.md index 96e8209a0..ddeebf733 100644 --- a/PENDING.md +++ b/PENDING.md @@ -57,5 +57,7 @@ BUG FIXES * SDK * [\#3582](https://github.com/cosmos/cosmos-sdk/pull/3582) Running `make test_unit was failing due to a missing tag + * [\#3617] Fix fee comparison when the required fees does not contain any denom + present in the tx fees. * Tendermint diff --git a/types/coin.go b/types/coin.go index 627febca6..675ddbb29 100644 --- a/types/coin.go +++ b/types/coin.go @@ -311,7 +311,7 @@ func (coins Coins) IsAnyGTE(coinsB Coins) bool { for _, coin := range coins { amt := coinsB.AmountOf(coin.Denom) - if coin.Amount.GTE(amt) { + if coin.Amount.GTE(amt) && !amt.IsZero() { return true } } diff --git a/types/coin_test.go b/types/coin_test.go index 52bdc54e9..277c29c46 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -517,6 +517,7 @@ func TestCoinsIsAnyGTE(t *testing.T) { assert.False(t, Coins{{"a", one}}.IsAnyGTE(Coins{})) assert.False(t, Coins{}.IsAnyGTE(Coins{{"a", one}})) assert.False(t, Coins{{"a", one}}.IsAnyGTE(Coins{{"a", two}})) + assert.False(t, Coins{{"a", one}}.IsAnyGTE(Coins{{"b", one}})) assert.True(t, Coins{{"a", one}, {"b", two}}.IsAnyGTE(Coins{{"a", two}, {"b", one}})) assert.True(t, Coins{{"a", one}}.IsAnyGTE(Coins{{"a", one}})) assert.True(t, Coins{{"a", two}}.IsAnyGTE(Coins{{"a", one}}))