diff --git a/go.mod b/go.mod index ee9584a3d..11e264f4e 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,6 @@ require ( github.com/tendermint/iavl v0.14.0-rc1 github.com/tendermint/tendermint v0.33.5 github.com/tendermint/tm-db v0.5.1 - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e google.golang.org/grpc v1.30.0 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/types/coin_test.go b/types/coin_test.go index 63b3fe38e..7177a180b 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -1,6 +1,7 @@ package types import ( + "fmt" "strings" "testing" @@ -27,6 +28,11 @@ func TestCoin(t *testing.T) { require.Equal(t, NewInt(5), NewCoin(testDenom1, NewInt(5)).Amount) } +func TestCoin_String(t *testing.T) { + coin := NewCoin(testDenom1, NewInt(10)) + require.Equal(t, fmt.Sprintf("10%s", testDenom1), coin.String()) +} + func TestIsEqualCoin(t *testing.T) { cases := []struct { inputOne Coin @@ -188,6 +194,43 @@ func TestCoinIsZero(t *testing.T) { // ---------------------------------------------------------------------------- // Coins tests +func TestCoins_String(t *testing.T) { + cases := []struct { + name string + input Coins + expected string + }{ + { + name: "empty coins", + input: Coins{}, + expected: "", + }, + { + name: "single coin", + input: Coins{ + {"tree", NewInt(1)}, + }, + expected: "1tree", + }, + { + name: "multiple coins", + input: Coins{ + {"tree", NewInt(1)}, + {"gas", NewInt(1)}, + {"mineral", NewInt(1)}, + }, + expected: "1tree,1gas,1mineral", + }, + } + + for _, tt := range cases { + tt := tt + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.expected, tt.input.String()) + }) + } +} + func TestIsZeroCoins(t *testing.T) { cases := []struct { inputOne Coins