From 1de9f35d811c7e701eb5fdc34ac950f67e4c9666 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 26 Apr 2022 16:13:43 -0400 Subject: [PATCH 01/22] updates --- math/go.mod | 11 ++ math/go.sum | 11 ++ {types => math}/int.go | 5 +- {types => math}/int_internal_test.go | 2 +- {types => math}/int_test.go | 160 +++++++++++++-------------- math/proto.go | 15 +++ {types => math}/uint.go | 2 +- 7 files changed, 121 insertions(+), 85 deletions(-) create mode 100644 math/go.mod create mode 100644 math/go.sum rename {types => math}/int.go (99%) rename {types => math}/int_internal_test.go (99%) rename {types => math}/int_test.go (69%) create mode 100644 math/proto.go rename {types => math}/uint.go (99%) diff --git a/math/go.mod b/math/go.mod new file mode 100644 index 000000000000..6f58ffc03bea --- /dev/null +++ b/math/go.mod @@ -0,0 +1,11 @@ +module github.com/cosmos/cosmos-sdk/math + +go 1.18 + +require github.com/stretchr/testify v1.7.0 + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/math/go.sum b/math/go.sum new file mode 100644 index 000000000000..acb88a48f684 --- /dev/null +++ b/math/go.sum @@ -0,0 +1,11 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/types/int.go b/math/int.go similarity index 99% rename from types/int.go rename to math/int.go index 04b808fbc69d..07080bbe1694 100644 --- a/types/int.go +++ b/math/int.go @@ -1,12 +1,11 @@ -package types +package math import ( "encoding" "encoding/json" "fmt" - "testing" - "math/big" + "testing" ) const maxBitLen = 256 diff --git a/types/int_internal_test.go b/math/int_internal_test.go similarity index 99% rename from types/int_internal_test.go rename to math/int_internal_test.go index 77d357bbf750..d2cb90240852 100644 --- a/types/int_internal_test.go +++ b/math/int_internal_test.go @@ -1,4 +1,4 @@ -package types +package math import ( "math/big" diff --git a/types/int_test.go b/math/int_test.go similarity index 69% rename from types/int_test.go rename to math/int_test.go index a6ec8c6d48bd..86bbe6d71a8f 100644 --- a/types/int_test.go +++ b/math/int_test.go @@ -1,4 +1,4 @@ -package types_test +package math_test import ( "fmt" @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/math" ) type intTestSuite struct { @@ -27,30 +27,30 @@ func (s *intTestSuite) SetupSuite() { func (s *intTestSuite) TestFromInt64() { for n := 0; n < 20; n++ { r := rand.Int63() - s.Require().Equal(r, sdk.NewInt(r).Int64()) + s.Require().Equal(r, math.NewInt(r).Int64()) } } func (s *intTestSuite) TestFromUint64() { for n := 0; n < 20; n++ { r := rand.Uint64() - s.Require().True(sdk.NewIntFromUint64(r).IsUint64()) - s.Require().Equal(r, sdk.NewIntFromUint64(r).Uint64()) + s.Require().True(math.NewIntFromUint64(r).IsUint64()) + s.Require().Equal(r, math.NewIntFromUint64(r).Uint64()) } } func (s *intTestSuite) TestIntPanic() { // Max Int = 2^256-1 = 1.1579209e+77 // Min Int = -(2^256-1) = -1.1579209e+77 - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(4, 76) }) - i1 := sdk.NewIntWithDecimal(4, 76) - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(5, 76) }) - i2 := sdk.NewIntWithDecimal(5, 76) - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(6, 76) }) - i3 := sdk.NewIntWithDecimal(6, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(4, 76) }) + i1 := math.NewIntWithDecimal(4, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(5, 76) }) + i2 := math.NewIntWithDecimal(5, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(6, 76) }) + i3 := math.NewIntWithDecimal(6, 76) - s.Require().Panics(func() { sdk.NewIntWithDecimal(2, 77) }) - s.Require().Panics(func() { sdk.NewIntWithDecimal(9, 80) }) + s.Require().Panics(func() { math.NewIntWithDecimal(2, 77) }) + s.Require().Panics(func() { math.NewIntWithDecimal(9, 80) }) // Overflow check s.Require().NotPanics(func() { i1.Add(i1) }) @@ -84,20 +84,20 @@ func (s *intTestSuite) TestIntPanic() { s.Require().Panics(func() { i3.Mul(i3.Neg()) }) // Bound check - intmax := sdk.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) + intmax := math.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) intmin := intmax.Neg() - s.Require().NotPanics(func() { intmax.Add(sdk.ZeroInt()) }) - s.Require().NotPanics(func() { intmin.Sub(sdk.ZeroInt()) }) - s.Require().Panics(func() { intmax.Add(sdk.OneInt()) }) - s.Require().Panics(func() { intmin.Sub(sdk.OneInt()) }) + s.Require().NotPanics(func() { intmax.Add(math.ZeroInt()) }) + s.Require().NotPanics(func() { intmin.Sub(math.ZeroInt()) }) + s.Require().Panics(func() { intmax.Add(math.OneInt()) }) + s.Require().Panics(func() { intmin.Sub(math.OneInt()) }) - s.Require().NotPanics(func() { sdk.NewIntFromBigInt(nil) }) - s.Require().True(sdk.NewIntFromBigInt(nil).IsNil()) + s.Require().NotPanics(func() { math.NewIntFromBigInt(nil) }) + s.Require().True(math.NewIntFromBigInt(nil).IsNil()) // Division-by-zero check - s.Require().Panics(func() { i1.Quo(sdk.NewInt(0)) }) + s.Require().Panics(func() { i1.Quo(math.NewInt(0)) }) - s.Require().NotPanics(func() { sdk.Int{}.BigInt() }) + s.Require().NotPanics(func() { math.Int{}.BigInt() }) } // Tests below uses randomness @@ -107,17 +107,17 @@ func (s *intTestSuite) TestIntPanic() { func (s *intTestSuite) TestIdentInt() { for d := 0; d < 1000; d++ { n := rand.Int63() - i := sdk.NewInt(n) + i := math.NewInt(n) - ifromstr, ok := sdk.NewIntFromString(strconv.FormatInt(n, 10)) + ifromstr, ok := math.NewIntFromString(strconv.FormatInt(n, 10)) s.Require().True(ok) cases := []int64{ i.Int64(), i.BigInt().Int64(), ifromstr.Int64(), - sdk.NewIntFromBigInt(big.NewInt(n)).Int64(), - sdk.NewIntWithDecimal(n, 0).Int64(), + math.NewIntFromBigInt(big.NewInt(n)).Int64(), + math.NewIntWithDecimal(n, 0).Int64(), } for tcnum, tc := range cases { @@ -143,12 +143,12 @@ func maxint(i1, i2 int64) int64 { func (s *intTestSuite) TestArithInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := sdk.NewInt(n1) + i1 := math.NewInt(n1) n2 := int64(rand.Int31()) - i2 := sdk.NewInt(n2) + i2 := math.NewInt(n2) cases := []struct { - ires sdk.Int + ires math.Int nres int64 }{ {i1.Add(i2), n1 + n2}, @@ -159,8 +159,8 @@ func (s *intTestSuite) TestArithInt() { {i1.SubRaw(n2), n1 - n2}, {i1.MulRaw(n2), n1 * n2}, {i1.QuoRaw(n2), n1 / n2}, - {sdk.MinInt(i1, i2), minint(n1, n2)}, - {sdk.MaxInt(i1, i2), maxint(n1, n2)}, + {math.MinInt(i1, i2), minint(n1, n2)}, + {math.MaxInt(i1, i2), maxint(n1, n2)}, {i1.Neg(), -n1}, {i1.Abs(), n1}, {i1.Neg().Abs(), n1}, @@ -176,9 +176,9 @@ func (s *intTestSuite) TestArithInt() { func (s *intTestSuite) TestCompInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := sdk.NewInt(n1) + i1 := math.NewInt(n1) n2 := int64(rand.Int31()) - i2 := sdk.NewInt(n2) + i2 := math.NewInt(n2) cases := []struct { ires bool @@ -196,93 +196,93 @@ func (s *intTestSuite) TestCompInt() { } } -func randint() sdk.Int { - return sdk.NewInt(rand.Int63()) +func randint() math.Int { + return math.NewInt(rand.Int63()) } func (s *intTestSuite) TestImmutabilityAllInt() { - ops := []func(*sdk.Int){ - func(i *sdk.Int) { _ = i.Add(randint()) }, - func(i *sdk.Int) { _ = i.Sub(randint()) }, - func(i *sdk.Int) { _ = i.Mul(randint()) }, - func(i *sdk.Int) { _ = i.Quo(randint()) }, - func(i *sdk.Int) { _ = i.AddRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.SubRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.MulRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.QuoRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.Neg() }, - func(i *sdk.Int) { _ = i.Abs() }, - func(i *sdk.Int) { _ = i.IsZero() }, - func(i *sdk.Int) { _ = i.Sign() }, - func(i *sdk.Int) { _ = i.Equal(randint()) }, - func(i *sdk.Int) { _ = i.GT(randint()) }, - func(i *sdk.Int) { _ = i.LT(randint()) }, - func(i *sdk.Int) { _ = i.String() }, + ops := []func(*math.Int){ + func(i *math.Int) { _ = i.Add(randint()) }, + func(i *math.Int) { _ = i.Sub(randint()) }, + func(i *math.Int) { _ = i.Mul(randint()) }, + func(i *math.Int) { _ = i.Quo(randint()) }, + func(i *math.Int) { _ = i.AddRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.SubRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.MulRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.QuoRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.Neg() }, + func(i *math.Int) { _ = i.Abs() }, + func(i *math.Int) { _ = i.IsZero() }, + func(i *math.Int) { _ = i.Sign() }, + func(i *math.Int) { _ = i.Equal(randint()) }, + func(i *math.Int) { _ = i.GT(randint()) }, + func(i *math.Int) { _ = i.LT(randint()) }, + func(i *math.Int) { _ = i.String() }, } for i := 0; i < 1000; i++ { n := rand.Int63() - ni := sdk.NewInt(n) + ni := math.NewInt(n) for opnum, op := range ops { op(&ni) s.Require().Equal(n, ni.Int64(), "Int is modified by operation. tc #%d", opnum) - s.Require().Equal(sdk.NewInt(n), ni, "Int is modified by operation. tc #%d", opnum) + s.Require().Equal(math.NewInt(n), ni, "Int is modified by operation. tc #%d", opnum) } } } func (s *intTestSuite) TestEncodingTableInt() { - var i sdk.Int + var i math.Int cases := []struct { - i sdk.Int + i math.Int jsonBz []byte rawBz []byte }{ { - sdk.NewInt(0), + math.NewInt(0), []byte("\"0\""), []byte{0x30}, }, { - sdk.NewInt(100), + math.NewInt(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - sdk.NewInt(-100), + math.NewInt(-100), []byte("\"-100\""), []byte{0x2d, 0x31, 0x30, 0x30}, }, { - sdk.NewInt(51842), + math.NewInt(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewInt(-51842), + math.NewInt(-51842), []byte("\"-51842\""), []byte{0x2d, 0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewInt(19513368), + math.NewInt(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewInt(-19513368), + math.NewInt(-19513368), []byte("\"-19513368\""), []byte{0x2d, 0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewInt(999999999999), + math.NewInt(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, { - sdk.NewInt(-999999999999), + math.NewInt(-999999999999), []byte("\"-999999999999\""), []byte{0x2d, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -308,35 +308,35 @@ func (s *intTestSuite) TestEncodingTableInt() { } func (s *intTestSuite) TestEncodingTableUint() { - var i sdk.Uint + var i math.Uint cases := []struct { - i sdk.Uint + i math.Uint jsonBz []byte rawBz []byte }{ { - sdk.NewUint(0), + math.NewUint(0), []byte("\"0\""), []byte{0x30}, }, { - sdk.NewUint(100), + math.NewUint(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - sdk.NewUint(51842), + math.NewUint(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewUint(19513368), + math.NewUint(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewUint(999999999999), + math.NewUint(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -377,19 +377,19 @@ func (s *intTestSuite) TestIntMod() { for _, tt := range tests { if tt.wantPanic { - s.Require().Panics(func() { sdk.NewInt(tt.x).Mod(sdk.NewInt(tt.y)) }) - s.Require().Panics(func() { sdk.NewInt(tt.x).ModRaw(tt.y) }) + s.Require().Panics(func() { math.NewInt(tt.x).Mod(math.NewInt(tt.y)) }) + s.Require().Panics(func() { math.NewInt(tt.x).ModRaw(tt.y) }) return } - s.Require().True(sdk.NewInt(tt.x).Mod(sdk.NewInt(tt.y)).Equal(sdk.NewInt(tt.ret))) - s.Require().True(sdk.NewInt(tt.x).ModRaw(tt.y).Equal(sdk.NewInt(tt.ret))) + s.Require().True(math.NewInt(tt.x).Mod(math.NewInt(tt.y)).Equal(math.NewInt(tt.ret))) + s.Require().True(math.NewInt(tt.x).ModRaw(tt.y).Equal(math.NewInt(tt.ret))) } } func (s *intTestSuite) TestIntEq() { - _, resp, _, _, _ := sdk.IntEq(s.T(), sdk.ZeroInt(), sdk.ZeroInt()) + _, resp, _, _, _ := math.IntEq(s.T(), math.ZeroInt(), math.ZeroInt()) s.Require().True(resp) - _, resp, _, _, _ = sdk.IntEq(s.T(), sdk.OneInt(), sdk.ZeroInt()) + _, resp, _, _, _ = math.IntEq(s.T(), math.OneInt(), math.ZeroInt()) s.Require().False(resp) } @@ -410,12 +410,12 @@ func TestRoundTripMarshalToInt(t *testing.T) { t.Parallel() var scratch [20]byte - iv := sdk.NewInt(value) + iv := math.NewInt(value) n, err := iv.MarshalTo(scratch[:]) if err != nil { t.Fatal(err) } - rt := new(sdk.Int) + rt := new(math.Int) if err := rt.Unmarshal(scratch[:n]); err != nil { t.Fatal(err) } diff --git a/math/proto.go b/math/proto.go new file mode 100644 index 000000000000..ab8a59143157 --- /dev/null +++ b/math/proto.go @@ -0,0 +1,15 @@ +package math + +// CustomProtobufType defines the interface custom gogo proto types must implement +// in order to be used as a "customtype" extension. +// +// ref: https://github.com/gogo/protobuf/blob/master/custom_types.md +type CustomProtobufType interface { + Marshal() ([]byte, error) + MarshalTo(data []byte) (n int, err error) + Unmarshal(data []byte) error + Size() int + + MarshalJSON() ([]byte, error) + UnmarshalJSON(data []byte) error +} diff --git a/types/uint.go b/math/uint.go similarity index 99% rename from types/uint.go rename to math/uint.go index dbdd17bd58a9..8fb19d54e45d 100644 --- a/types/uint.go +++ b/math/uint.go @@ -1,4 +1,4 @@ -package types +package math import ( "errors" From d49d0c23708ff0b9523408b6c89fbb285c67386a Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 09:15:23 -0400 Subject: [PATCH 02/22] updates --- math/int.go | 11 +- math/proto.go | 4 +- math/uint.go | 2 +- {types => math}/uint_internal_test.go | 2 +- math/uint_test.go | 325 +++++++++++++++++++++++++ types/int.go | 5 + types/proto.go | 15 -- types/uint_test.go | 326 -------------------------- 8 files changed, 335 insertions(+), 355 deletions(-) rename {types => math}/uint_internal_test.go (98%) create mode 100644 math/uint_test.go create mode 100644 types/int.go delete mode 100644 types/proto.go delete mode 100644 types/uint_test.go diff --git a/math/int.go b/math/int.go index 07080bbe1694..d1689c12758b 100644 --- a/math/int.go +++ b/math/int.go @@ -66,7 +66,7 @@ func unmarshalText(i *big.Int, text string) error { return nil } -var _ CustomProtobufType = (*Int)(nil) +var _ customProtobufType = (*Int)(nil) // Int wraps big.Int with a 257 bit range bound // Checks overflow, underflow and division by zero @@ -150,11 +150,6 @@ func ZeroInt() Int { return Int{big.NewInt(0)} } // OneInt returns Int value with one func OneInt() Int { return Int{big.NewInt(1)} } -// ToDec converts Int to Dec -func (i Int) ToDec() Dec { - return NewDecFromInt(i) -} - // Int64 converts Int to int64 // Panics if the value is out of range func (i Int) Int64() int64 { @@ -436,7 +431,3 @@ func (i *Int) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } func IntEq(t *testing.T, exp, got Int) (*testing.T, bool, string, string, string) { return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } - -func (ip IntProto) String() string { - return ip.Int.String() -} diff --git a/math/proto.go b/math/proto.go index ab8a59143157..86e78bafa90d 100644 --- a/math/proto.go +++ b/math/proto.go @@ -1,10 +1,10 @@ package math -// CustomProtobufType defines the interface custom gogo proto types must implement +// customProtobufType defines the interface custom gogo proto types must implement // in order to be used as a "customtype" extension. // // ref: https://github.com/gogo/protobuf/blob/master/custom_types.md -type CustomProtobufType interface { +type customProtobufType interface { Marshal() ([]byte, error) MarshalTo(data []byte) (n int, err error) Unmarshal(data []byte) error diff --git a/math/uint.go b/math/uint.go index 8fb19d54e45d..d5842f206e42 100644 --- a/math/uint.go +++ b/math/uint.go @@ -49,7 +49,7 @@ func ZeroUint() Uint { return Uint{big.NewInt(0)} } // OneUint returns Uint value with one. func OneUint() Uint { return Uint{big.NewInt(1)} } -var _ CustomProtobufType = (*Uint)(nil) +var _ customProtobufType = (*Uint)(nil) // Uint64 converts Uint to uint64 // Panics if the value is out of range diff --git a/types/uint_internal_test.go b/math/uint_internal_test.go similarity index 98% rename from types/uint_internal_test.go rename to math/uint_internal_test.go index a39869cac759..3f86c93604af 100644 --- a/types/uint_internal_test.go +++ b/math/uint_internal_test.go @@ -1,4 +1,4 @@ -package types +package math import ( "math/big" diff --git a/math/uint_test.go b/math/uint_test.go new file mode 100644 index 000000000000..b19d84a97a55 --- /dev/null +++ b/math/uint_test.go @@ -0,0 +1,325 @@ +package math_test + +import ( + "fmt" + "math" + "math/big" + "math/rand" + "testing" + + sdkmath "github.com/cosmos/cosmos-sdk/math" + "github.com/stretchr/testify/suite" +) + +type uintTestSuite struct { + suite.Suite +} + +func TestUnitTestSuite(t *testing.T) { + suite.Run(t, new(uintTestSuite)) +} + +func (s *uintTestSuite) SetupSuite() { + s.T().Parallel() +} + +func (s *uintTestSuite) TestUintPanics() { + // Max Uint = 1.15e+77 + // Min Uint = 0 + u1 := sdkmath.NewUint(0) + u2 := sdkmath.OneUint() + + s.Require().Equal(uint64(0), u1.Uint64()) + s.Require().Equal(uint64(1), u2.Uint64()) + + s.Require().Panics(func() { sdkmath.NewUintFromBigInt(big.NewInt(-5)) }) + s.Require().Panics(func() { sdkmath.NewUintFromString("-1") }) + s.Require().NotPanics(func() { + s.Require().True(sdkmath.NewUintFromString("0").Equal(sdkmath.ZeroUint())) + s.Require().True(sdkmath.NewUintFromString("5").Equal(sdkmath.NewUint(5))) + }) + + // Overflow check + s.Require().True(u1.Add(u1).Equal(sdkmath.ZeroUint())) + s.Require().True(u1.Add(sdkmath.OneUint()).Equal(sdkmath.OneUint())) + s.Require().Equal(uint64(0), u1.Uint64()) + s.Require().Equal(uint64(1), sdkmath.OneUint().Uint64()) + s.Require().Panics(func() { u1.SubUint64(2) }) + s.Require().True(u1.SubUint64(0).Equal(sdkmath.ZeroUint())) + s.Require().True(u2.Add(sdkmath.OneUint()).Sub(sdkmath.OneUint()).Equal(sdkmath.OneUint())) // i2 == 1 + s.Require().True(u2.Add(sdkmath.OneUint()).Mul(sdkmath.NewUint(5)).Equal(sdkmath.NewUint(10))) // i2 == 10 + s.Require().True(sdkmath.NewUint(7).Quo(sdkmath.NewUint(2)).Equal(sdkmath.NewUint(3))) + s.Require().True(sdkmath.NewUint(0).Quo(sdkmath.NewUint(2)).Equal(sdkmath.ZeroUint())) + s.Require().True(sdkmath.NewUint(5).MulUint64(4).Equal(sdkmath.NewUint(20))) + s.Require().True(sdkmath.NewUint(5).MulUint64(0).Equal(sdkmath.ZeroUint())) + + uintmax := sdkmath.NewUintFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) + uintmin := sdkmath.ZeroUint() + + // divs by zero + s.Require().Panics(func() { sdkmath.OneUint().Mul(sdkmath.ZeroUint().SubUint64(uint64(1))) }) + s.Require().Panics(func() { sdkmath.OneUint().QuoUint64(0) }) + s.Require().Panics(func() { sdkmath.OneUint().Quo(sdkmath.ZeroUint()) }) + s.Require().Panics(func() { sdkmath.ZeroUint().QuoUint64(0) }) + s.Require().Panics(func() { sdkmath.OneUint().Quo(sdkmath.ZeroUint().Sub(sdkmath.OneUint())) }) + s.Require().Panics(func() { uintmax.Add(sdkmath.OneUint()) }) + s.Require().Panics(func() { uintmax.Incr() }) + s.Require().Panics(func() { uintmin.Sub(sdkmath.OneUint()) }) + s.Require().Panics(func() { uintmin.Decr() }) + + s.Require().Equal(uint64(0), sdkmath.MinUint(sdkmath.ZeroUint(), sdkmath.OneUint()).Uint64()) + s.Require().Equal(uint64(1), sdkmath.MaxUint(sdkmath.ZeroUint(), sdkmath.OneUint()).Uint64()) + + // comparison ops + s.Require().True( + sdkmath.OneUint().GT(sdkmath.ZeroUint()), + ) + s.Require().False( + sdkmath.OneUint().LT(sdkmath.ZeroUint()), + ) + s.Require().True( + sdkmath.OneUint().GTE(sdkmath.ZeroUint()), + ) + s.Require().False( + sdkmath.OneUint().LTE(sdkmath.ZeroUint()), + ) + + s.Require().False(sdkmath.ZeroUint().GT(sdkmath.OneUint())) + s.Require().True(sdkmath.ZeroUint().LT(sdkmath.OneUint())) + s.Require().False(sdkmath.ZeroUint().GTE(sdkmath.OneUint())) + s.Require().True(sdkmath.ZeroUint().LTE(sdkmath.OneUint())) +} + +func (s *uintTestSuite) TestArithUint() { + for d := 0; d < 1000; d++ { + n1 := uint64(rand.Uint32()) + u1 := sdkmath.NewUint(n1) + n2 := uint64(rand.Uint32()) + u2 := sdkmath.NewUint(n2) + + cases := []struct { + ures sdkmath.Uint + nres uint64 + }{ + {u1.Add(u2), n1 + n2}, + {u1.Mul(u2), n1 * n2}, + {u1.Quo(u2), n1 / n2}, + {u1.AddUint64(n2), n1 + n2}, + {u1.MulUint64(n2), n1 * n2}, + {u1.QuoUint64(n2), n1 / n2}, + {sdkmath.MinUint(u1, u2), minuint(n1, n2)}, + {sdkmath.MaxUint(u1, u2), maxuint(n1, n2)}, + {u1.Incr(), n1 + 1}, + } + + for tcnum, tc := range cases { + s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint arithmetic operation does not match with uint64 operation. tc #%d", tcnum) + } + + if n2 > n1 { + n1, n2 = n2, n1 + u1, u2 = sdkmath.NewUint(n1), sdkmath.NewUint(n2) + } + + subs := []struct { + ures sdkmath.Uint + nres uint64 + }{ + {u1.Sub(u2), n1 - n2}, + {u1.SubUint64(n2), n1 - n2}, + {u1.Decr(), n1 - 1}, + } + + for tcnum, tc := range subs { + s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint subtraction does not match with uint64 operation. tc #%d", tcnum) + } + } +} + +func (s *uintTestSuite) TestCompUint() { + for d := 0; d < 10000; d++ { + n1 := rand.Uint64() + i1 := sdkmath.NewUint(n1) + n2 := rand.Uint64() + i2 := sdkmath.NewUint(n2) + + cases := []struct { + ires bool + nres bool + }{ + {i1.Equal(i2), n1 == n2}, + {i1.GT(i2), n1 > n2}, + {i1.LT(i2), n1 < n2}, + {i1.GTE(i2), !i1.LT(i2)}, + {!i1.GTE(i2), i1.LT(i2)}, + {i1.LTE(i2), n1 <= n2}, + {i2.LTE(i1), n2 <= n1}, + } + + for tcnum, tc := range cases { + s.Require().Equal(tc.nres, tc.ires, "Uint comparison operation does not match with uint64 operation. tc #%d", tcnum) + } + } +} + +func (s *uintTestSuite) TestImmutabilityAllUint() { + ops := []func(*sdkmath.Uint){ + func(i *sdkmath.Uint) { _ = i.Add(sdkmath.NewUint(rand.Uint64())) }, + func(i *sdkmath.Uint) { _ = i.Sub(sdkmath.NewUint(rand.Uint64() % i.Uint64())) }, + func(i *sdkmath.Uint) { _ = i.Mul(randuint()) }, + func(i *sdkmath.Uint) { _ = i.Quo(randuint()) }, + func(i *sdkmath.Uint) { _ = i.AddUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.MulUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.QuoUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.IsZero() }, + func(i *sdkmath.Uint) { _ = i.Equal(randuint()) }, + func(i *sdkmath.Uint) { _ = i.GT(randuint()) }, + func(i *sdkmath.Uint) { _ = i.GTE(randuint()) }, + func(i *sdkmath.Uint) { _ = i.LT(randuint()) }, + func(i *sdkmath.Uint) { _ = i.LTE(randuint()) }, + func(i *sdkmath.Uint) { _ = i.String() }, + func(i *sdkmath.Uint) { _ = i.Incr() }, + func(i *sdkmath.Uint) { + if i.IsZero() { + return + } + + _ = i.Decr() + }, + } + + for i := 0; i < 1000; i++ { + n := rand.Uint64() + ni := sdkmath.NewUint(n) + + for opnum, op := range ops { + op(&ni) + + s.Require().Equal(n, ni.Uint64(), "Uint is modified by operation. #%d", opnum) + s.Require().Equal(sdkmath.NewUint(n), ni, "Uint is modified by operation. #%d", opnum) + } + } +} + +func (s *uintTestSuite) TestSafeSub() { + testCases := []struct { + x, y sdkmath.Uint + expected uint64 + panic bool + }{ + {sdkmath.NewUint(0), sdkmath.NewUint(0), 0, false}, + {sdkmath.NewUint(10), sdkmath.NewUint(5), 5, false}, + {sdkmath.NewUint(5), sdkmath.NewUint(10), 5, true}, + {sdkmath.NewUint(math.MaxUint64), sdkmath.NewUint(0), math.MaxUint64, false}, + } + + for i, tc := range testCases { + tc := tc + if tc.panic { + s.Require().Panics(func() { tc.x.Sub(tc.y) }) + continue + } + s.Require().Equal( + tc.expected, tc.x.Sub(tc.y).Uint64(), + "invalid subtraction result; x: %s, y: %s, tc: #%d", tc.x, tc.y, i, + ) + } +} + +func (s *uintTestSuite) TestParseUint() { + type args struct { + s string + } + tests := []struct { + name string + args args + want sdkmath.Uint + wantErr bool + }{ + {"malformed", args{"malformed"}, sdkmath.Uint{}, true}, + {"empty", args{""}, sdkmath.Uint{}, true}, + {"positive", args{"50"}, sdkmath.NewUint(uint64(50)), false}, + {"negative", args{"-1"}, sdkmath.Uint{}, true}, + {"zero", args{"0"}, sdkmath.ZeroUint(), false}, + } + for _, tt := range tests { + got, err := sdkmath.ParseUint(tt.args.s) + if tt.wantErr { + s.Require().Error(err) + continue + } + s.Require().NoError(err) + s.Require().True(got.Equal(tt.want)) + } +} + +func randuint() sdkmath.Uint { + return sdkmath.NewUint(rand.Uint64()) +} + +func (s *uintTestSuite) TestRelativePow() { + tests := []struct { + args []sdkmath.Uint + want sdkmath.Uint + }{ + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.ZeroUint(), sdkmath.OneUint()}, sdkmath.OneUint()}, + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.ZeroUint(), sdkmath.NewUint(10)}, sdkmath.NewUint(10)}, + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.OneUint(), sdkmath.NewUint(10)}, sdkmath.ZeroUint()}, + {[]sdkmath.Uint{sdkmath.NewUint(10), sdkmath.NewUint(2), sdkmath.OneUint()}, sdkmath.NewUint(100)}, + {[]sdkmath.Uint{sdkmath.NewUint(210), sdkmath.NewUint(2), sdkmath.NewUint(100)}, sdkmath.NewUint(441)}, + {[]sdkmath.Uint{sdkmath.NewUint(2100), sdkmath.NewUint(2), sdkmath.NewUint(1000)}, sdkmath.NewUint(4410)}, + {[]sdkmath.Uint{sdkmath.NewUint(1000000001547125958), sdkmath.NewUint(600), sdkmath.NewUint(1000000000000000000)}, sdkmath.NewUint(1000000928276004850)}, + } + for i, tc := range tests { + res := sdkmath.RelativePow(tc.args[0], tc.args[1], tc.args[2]) + s.Require().Equal(tc.want, res, "unexpected result for test case %d, input: %v, got: %v", i, tc.args, res) + } +} + +func minuint(i1, i2 uint64) uint64 { + if i1 < i2 { + return i1 + } + return i2 +} + +func maxuint(i1, i2 uint64) uint64 { + if i1 > i2 { + return i1 + } + return i2 +} + +func TestRoundTripMarshalToUint(t *testing.T) { + var values = []uint64{ + 0, + 1, + 1 << 10, + 1<<10 - 3, + 1<<63 - 1, + 1<<32 - 7, + 1<<22 - 8, + } + + for _, value := range values { + value := value + t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { + t.Parallel() + + var scratch [20]byte + uv := sdkmath.NewUint(value) + n, err := uv.MarshalTo(scratch[:]) + if err != nil { + t.Fatal(err) + } + rt := new(sdkmath.Uint) + if err := rt.Unmarshal(scratch[:n]); err != nil { + t.Fatal(err) + } + if !rt.Equal(uv) { + t.Fatalf("roundtrip=%q != original=%q", rt, uv) + } + }) + } +} diff --git a/types/int.go b/types/int.go new file mode 100644 index 000000000000..391283d0b9e4 --- /dev/null +++ b/types/int.go @@ -0,0 +1,5 @@ +package types + +func (ip IntProto) String() string { + return ip.Int.String() +} diff --git a/types/proto.go b/types/proto.go deleted file mode 100644 index 5f2df428d27d..000000000000 --- a/types/proto.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -// CustomProtobufType defines the interface custom gogo proto types must implement -// in order to be used as a "customtype" extension. -// -// ref: https://github.com/gogo/protobuf/blob/master/custom_types.md -type CustomProtobufType interface { - Marshal() ([]byte, error) - MarshalTo(data []byte) (n int, err error) - Unmarshal(data []byte) error - Size() int - - MarshalJSON() ([]byte, error) - UnmarshalJSON(data []byte) error -} diff --git a/types/uint_test.go b/types/uint_test.go deleted file mode 100644 index b91f9ab4a96a..000000000000 --- a/types/uint_test.go +++ /dev/null @@ -1,326 +0,0 @@ -package types_test - -import ( - "fmt" - "math" - "math/big" - "math/rand" - "testing" - - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type uintTestSuite struct { - suite.Suite -} - -func TestUnitTestSuite(t *testing.T) { - suite.Run(t, new(uintTestSuite)) -} - -func (s *uintTestSuite) SetupSuite() { - s.T().Parallel() -} - -func (s *uintTestSuite) TestUintPanics() { - // Max Uint = 1.15e+77 - // Min Uint = 0 - u1 := sdk.NewUint(0) - u2 := sdk.OneUint() - - s.Require().Equal(uint64(0), u1.Uint64()) - s.Require().Equal(uint64(1), u2.Uint64()) - - s.Require().Panics(func() { sdk.NewUintFromBigInt(big.NewInt(-5)) }) - s.Require().Panics(func() { sdk.NewUintFromString("-1") }) - s.Require().NotPanics(func() { - s.Require().True(sdk.NewUintFromString("0").Equal(sdk.ZeroUint())) - s.Require().True(sdk.NewUintFromString("5").Equal(sdk.NewUint(5))) - }) - - // Overflow check - s.Require().True(u1.Add(u1).Equal(sdk.ZeroUint())) - s.Require().True(u1.Add(sdk.OneUint()).Equal(sdk.OneUint())) - s.Require().Equal(uint64(0), u1.Uint64()) - s.Require().Equal(uint64(1), sdk.OneUint().Uint64()) - s.Require().Panics(func() { u1.SubUint64(2) }) - s.Require().True(u1.SubUint64(0).Equal(sdk.ZeroUint())) - s.Require().True(u2.Add(sdk.OneUint()).Sub(sdk.OneUint()).Equal(sdk.OneUint())) // i2 == 1 - s.Require().True(u2.Add(sdk.OneUint()).Mul(sdk.NewUint(5)).Equal(sdk.NewUint(10))) // i2 == 10 - s.Require().True(sdk.NewUint(7).Quo(sdk.NewUint(2)).Equal(sdk.NewUint(3))) - s.Require().True(sdk.NewUint(0).Quo(sdk.NewUint(2)).Equal(sdk.ZeroUint())) - s.Require().True(sdk.NewUint(5).MulUint64(4).Equal(sdk.NewUint(20))) - s.Require().True(sdk.NewUint(5).MulUint64(0).Equal(sdk.ZeroUint())) - - uintmax := sdk.NewUintFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) - uintmin := sdk.ZeroUint() - - // divs by zero - s.Require().Panics(func() { sdk.OneUint().Mul(sdk.ZeroUint().SubUint64(uint64(1))) }) - s.Require().Panics(func() { sdk.OneUint().QuoUint64(0) }) - s.Require().Panics(func() { sdk.OneUint().Quo(sdk.ZeroUint()) }) - s.Require().Panics(func() { sdk.ZeroUint().QuoUint64(0) }) - s.Require().Panics(func() { sdk.OneUint().Quo(sdk.ZeroUint().Sub(sdk.OneUint())) }) - s.Require().Panics(func() { uintmax.Add(sdk.OneUint()) }) - s.Require().Panics(func() { uintmax.Incr() }) - s.Require().Panics(func() { uintmin.Sub(sdk.OneUint()) }) - s.Require().Panics(func() { uintmin.Decr() }) - - s.Require().Equal(uint64(0), sdk.MinUint(sdk.ZeroUint(), sdk.OneUint()).Uint64()) - s.Require().Equal(uint64(1), sdk.MaxUint(sdk.ZeroUint(), sdk.OneUint()).Uint64()) - - // comparison ops - s.Require().True( - sdk.OneUint().GT(sdk.ZeroUint()), - ) - s.Require().False( - sdk.OneUint().LT(sdk.ZeroUint()), - ) - s.Require().True( - sdk.OneUint().GTE(sdk.ZeroUint()), - ) - s.Require().False( - sdk.OneUint().LTE(sdk.ZeroUint()), - ) - - s.Require().False(sdk.ZeroUint().GT(sdk.OneUint())) - s.Require().True(sdk.ZeroUint().LT(sdk.OneUint())) - s.Require().False(sdk.ZeroUint().GTE(sdk.OneUint())) - s.Require().True(sdk.ZeroUint().LTE(sdk.OneUint())) -} - -func (s *uintTestSuite) TestArithUint() { - for d := 0; d < 1000; d++ { - n1 := uint64(rand.Uint32()) - u1 := sdk.NewUint(n1) - n2 := uint64(rand.Uint32()) - u2 := sdk.NewUint(n2) - - cases := []struct { - ures sdk.Uint - nres uint64 - }{ - {u1.Add(u2), n1 + n2}, - {u1.Mul(u2), n1 * n2}, - {u1.Quo(u2), n1 / n2}, - {u1.AddUint64(n2), n1 + n2}, - {u1.MulUint64(n2), n1 * n2}, - {u1.QuoUint64(n2), n1 / n2}, - {sdk.MinUint(u1, u2), minuint(n1, n2)}, - {sdk.MaxUint(u1, u2), maxuint(n1, n2)}, - {u1.Incr(), n1 + 1}, - } - - for tcnum, tc := range cases { - s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint arithmetic operation does not match with uint64 operation. tc #%d", tcnum) - } - - if n2 > n1 { - n1, n2 = n2, n1 - u1, u2 = sdk.NewUint(n1), sdk.NewUint(n2) - } - - subs := []struct { - ures sdk.Uint - nres uint64 - }{ - {u1.Sub(u2), n1 - n2}, - {u1.SubUint64(n2), n1 - n2}, - {u1.Decr(), n1 - 1}, - } - - for tcnum, tc := range subs { - s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint subtraction does not match with uint64 operation. tc #%d", tcnum) - } - } -} - -func (s *uintTestSuite) TestCompUint() { - for d := 0; d < 10000; d++ { - n1 := rand.Uint64() - i1 := sdk.NewUint(n1) - n2 := rand.Uint64() - i2 := sdk.NewUint(n2) - - cases := []struct { - ires bool - nres bool - }{ - {i1.Equal(i2), n1 == n2}, - {i1.GT(i2), n1 > n2}, - {i1.LT(i2), n1 < n2}, - {i1.GTE(i2), !i1.LT(i2)}, - {!i1.GTE(i2), i1.LT(i2)}, - {i1.LTE(i2), n1 <= n2}, - {i2.LTE(i1), n2 <= n1}, - } - - for tcnum, tc := range cases { - s.Require().Equal(tc.nres, tc.ires, "Uint comparison operation does not match with uint64 operation. tc #%d", tcnum) - } - } -} - -func (s *uintTestSuite) TestImmutabilityAllUint() { - ops := []func(*sdk.Uint){ - func(i *sdk.Uint) { _ = i.Add(sdk.NewUint(rand.Uint64())) }, - func(i *sdk.Uint) { _ = i.Sub(sdk.NewUint(rand.Uint64() % i.Uint64())) }, - func(i *sdk.Uint) { _ = i.Mul(randuint()) }, - func(i *sdk.Uint) { _ = i.Quo(randuint()) }, - func(i *sdk.Uint) { _ = i.AddUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) }, - func(i *sdk.Uint) { _ = i.MulUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.QuoUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.IsZero() }, - func(i *sdk.Uint) { _ = i.Equal(randuint()) }, - func(i *sdk.Uint) { _ = i.GT(randuint()) }, - func(i *sdk.Uint) { _ = i.GTE(randuint()) }, - func(i *sdk.Uint) { _ = i.LT(randuint()) }, - func(i *sdk.Uint) { _ = i.LTE(randuint()) }, - func(i *sdk.Uint) { _ = i.String() }, - func(i *sdk.Uint) { _ = i.Incr() }, - func(i *sdk.Uint) { - if i.IsZero() { - return - } - - _ = i.Decr() - }, - } - - for i := 0; i < 1000; i++ { - n := rand.Uint64() - ni := sdk.NewUint(n) - - for opnum, op := range ops { - op(&ni) - - s.Require().Equal(n, ni.Uint64(), "Uint is modified by operation. #%d", opnum) - s.Require().Equal(sdk.NewUint(n), ni, "Uint is modified by operation. #%d", opnum) - } - } -} - -func (s *uintTestSuite) TestSafeSub() { - testCases := []struct { - x, y sdk.Uint - expected uint64 - panic bool - }{ - {sdk.NewUint(0), sdk.NewUint(0), 0, false}, - {sdk.NewUint(10), sdk.NewUint(5), 5, false}, - {sdk.NewUint(5), sdk.NewUint(10), 5, true}, - {sdk.NewUint(math.MaxUint64), sdk.NewUint(0), math.MaxUint64, false}, - } - - for i, tc := range testCases { - tc := tc - if tc.panic { - s.Require().Panics(func() { tc.x.Sub(tc.y) }) - continue - } - s.Require().Equal( - tc.expected, tc.x.Sub(tc.y).Uint64(), - "invalid subtraction result; x: %s, y: %s, tc: #%d", tc.x, tc.y, i, - ) - } -} - -func (s *uintTestSuite) TestParseUint() { - type args struct { - s string - } - tests := []struct { - name string - args args - want sdk.Uint - wantErr bool - }{ - {"malformed", args{"malformed"}, sdk.Uint{}, true}, - {"empty", args{""}, sdk.Uint{}, true}, - {"positive", args{"50"}, sdk.NewUint(uint64(50)), false}, - {"negative", args{"-1"}, sdk.Uint{}, true}, - {"zero", args{"0"}, sdk.ZeroUint(), false}, - } - for _, tt := range tests { - got, err := sdk.ParseUint(tt.args.s) - if tt.wantErr { - s.Require().Error(err) - continue - } - s.Require().NoError(err) - s.Require().True(got.Equal(tt.want)) - } -} - -func randuint() sdk.Uint { - return sdk.NewUint(rand.Uint64()) -} - -func (s *uintTestSuite) TestRelativePow() { - tests := []struct { - args []sdk.Uint - want sdk.Uint - }{ - {[]sdk.Uint{sdk.ZeroUint(), sdk.ZeroUint(), sdk.OneUint()}, sdk.OneUint()}, - {[]sdk.Uint{sdk.ZeroUint(), sdk.ZeroUint(), sdk.NewUint(10)}, sdk.NewUint(10)}, - {[]sdk.Uint{sdk.ZeroUint(), sdk.OneUint(), sdk.NewUint(10)}, sdk.ZeroUint()}, - {[]sdk.Uint{sdk.NewUint(10), sdk.NewUint(2), sdk.OneUint()}, sdk.NewUint(100)}, - {[]sdk.Uint{sdk.NewUint(210), sdk.NewUint(2), sdk.NewUint(100)}, sdk.NewUint(441)}, - {[]sdk.Uint{sdk.NewUint(2100), sdk.NewUint(2), sdk.NewUint(1000)}, sdk.NewUint(4410)}, - {[]sdk.Uint{sdk.NewUint(1000000001547125958), sdk.NewUint(600), sdk.NewUint(1000000000000000000)}, sdk.NewUint(1000000928276004850)}, - } - for i, tc := range tests { - res := sdk.RelativePow(tc.args[0], tc.args[1], tc.args[2]) - s.Require().Equal(tc.want, res, "unexpected result for test case %d, input: %v, got: %v", i, tc.args, res) - } -} - -func minuint(i1, i2 uint64) uint64 { - if i1 < i2 { - return i1 - } - return i2 -} - -func maxuint(i1, i2 uint64) uint64 { - if i1 > i2 { - return i1 - } - return i2 -} - -func TestRoundTripMarshalToUint(t *testing.T) { - var values = []uint64{ - 0, - 1, - 1 << 10, - 1<<10 - 3, - 1<<63 - 1, - 1<<32 - 7, - 1<<22 - 8, - } - - for _, value := range values { - value := value - t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { - t.Parallel() - - var scratch [20]byte - uv := sdk.NewUint(value) - n, err := uv.MarshalTo(scratch[:]) - if err != nil { - t.Fatal(err) - } - rt := new(sdk.Uint) - if err := rt.Unmarshal(scratch[:n]); err != nil { - t.Fatal(err) - } - if !rt.Equal(uv) { - t.Fatalf("roundtrip=%q != original=%q", rt, uv) - } - }) - } -} From 57384ab2cfb91ed698b28c9d2502d47af7d1bd18 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 09:20:22 -0400 Subject: [PATCH 03/22] updates --- errors/CHANGELOG.md | 7 +------ math/CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ math/doc.go | 6 ++++++ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 math/CHANGELOG.md create mode 100644 math/doc.go diff --git a/errors/CHANGELOG.md b/errors/CHANGELOG.md index ec995cb13bdf..39b42c9457f6 100644 --- a/errors/CHANGELOG.md +++ b/errors/CHANGELOG.md @@ -15,10 +15,7 @@ Change log entries are to be added to the Unreleased section under the appropriate stanza (see below). Each entry should ideally include a tag and the Github issue reference in the following format: -* () \# message - -The issue numbers will later be link-ified during the release process so you do -not have to worry about including a link manually, but you can if you wish. +* () [#] Changelog message. Types of changes (Stanzas): @@ -26,8 +23,6 @@ Types of changes (Stanzas): "Improvements" for changes in existing functionality. "Deprecated" for soon-to-be removed features. "Bug Fixes" for any bug fixes. -"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users. -"CLI Breaking" for breaking CLI commands. "API Breaking" for breaking exported APIs used by developers building on SDK. Ref: https://keepachangelog.com/en/1.0.0/ --> diff --git a/math/CHANGELOG.md b/math/CHANGELOG.md new file mode 100644 index 000000000000..16de809f2717 --- /dev/null +++ b/math/CHANGELOG.md @@ -0,0 +1,32 @@ + + +# Changelog + +## [Unreleased] diff --git a/math/doc.go b/math/doc.go new file mode 100644 index 000000000000..17664a9531e0 --- /dev/null +++ b/math/doc.go @@ -0,0 +1,6 @@ +/* +Package math implements custom Cosmos SDK math types used for arithmetic +operations. Signed and unsigned integer types utilize Golang's standard library +big integers types, having a maximum bit length of 256 bits. +*/ +package math From ae3373c0098a0c9240c759be92e9854f8fc48668 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 09:24:08 -0400 Subject: [PATCH 04/22] updates --- types/int.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/int.go b/types/int.go index 391283d0b9e4..06b6b01b330b 100644 --- a/types/int.go +++ b/types/int.go @@ -1,5 +1,19 @@ package types +import ( + mathmod "github.com/cosmos/cosmos-sdk/math" +) + +// Type aliases to the SDK's math sub-module +// +// Deprecated: Functionality of this package has been moved to it's own module: +// github.com/cosmos/cosmos-sdk/math +// +// Please use the above module instead of this package. +var ( + Int = mathmod.Int +) + func (ip IntProto) String() string { return ip.Int.String() } From edda34be827364b024709c57e01c4542e9a917cd Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 09:24:29 -0400 Subject: [PATCH 05/22] updates --- types/{int.go => math.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename types/{int.go => math.go} (100%) diff --git a/types/int.go b/types/math.go similarity index 100% rename from types/int.go rename to types/math.go From 8ec1512951f562f3feb7d5fc9f59828db2d9944c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 12:37:14 -0400 Subject: [PATCH 06/22] updates --- go.mod | 18 +++++++++++------- types/math.go | 10 ++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f1245629b99c..078f00546088 100644 --- a/go.mod +++ b/go.mod @@ -59,6 +59,8 @@ require ( sigs.k8s.io/yaml v1.3.0 ) +require github.com/cosmos/cosmos-sdk/math v0.0.0-00010101000000-000000000000 + require ( cloud.google.com/go v0.100.2 // indirect cloud.google.com/go/compute v1.5.0 // indirect @@ -149,14 +151,16 @@ require ( nhooyr.io/websocket v1.8.6 // indirect ) -replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - -replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 +replace ( + github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 -// Fix upstream GHSA-h395-qcrw-5vmq vulnerability. -// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 -replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 + github.com/cosmos/cosmos-sdk/db => ./db + github.com/cosmos/cosmos-sdk/math => ./math -replace github.com/cosmos/cosmos-sdk/db => ./db + // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. + // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 + github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 + github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 +) retract v0.43.0 diff --git a/types/math.go b/types/math.go index 06b6b01b330b..9cb160e5fc2f 100644 --- a/types/math.go +++ b/types/math.go @@ -10,10 +10,16 @@ import ( // github.com/cosmos/cosmos-sdk/math // // Please use the above module instead of this package. -var ( - Int = mathmod.Int +type ( + Int = mathmod.Int + Uint = mathmod.Uint ) func (ip IntProto) String() string { return ip.Int.String() } + +// ToDec converts Int to Dec +func ToDec(i Int) Dec { + return NewDecFromInt(i) +} From 1eb86e4804aa558196c07d998318c8846f631068 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 14:45:10 -0400 Subject: [PATCH 07/22] updates --- math/int.go | 23 ++-- math/uint.go | 4 +- server/rosetta/converter.go | 3 +- simapp/simd/cmd/testnet.go | 3 +- simapp/state.go | 3 +- simapp/test_helpers.go | 9 +- testutil/network/network.go | 5 +- types/bench_test.go | 5 +- types/coin.go | 10 +- types/coin_benchmark_test.go | 10 +- types/coin_internal_test.go | 4 +- types/coin_test.go | 253 +++++++++++++++++----------------- types/dec_coin.go | 10 +- types/dec_coin_test.go | 43 +++--- types/decimal.go | 12 +- types/decimal_test.go | 41 +++--- types/denom.go | 2 +- types/denom_internal_test.go | 74 +++++----- types/events_test.go | 3 +- types/math.go | 8 +- types/proto.go | 15 ++ types/simulation/rand_util.go | 9 +- types/staking.go | 8 +- types/staking_test.go | 5 +- 24 files changed, 303 insertions(+), 259 deletions(-) create mode 100644 types/proto.go diff --git a/math/int.go b/math/int.go index d1689c12758b..4c1e9ceb8491 100644 --- a/math/int.go +++ b/math/int.go @@ -8,7 +8,8 @@ import ( "testing" ) -const maxBitLen = 256 +// MaxBitLen defines the maximum bit length supported bit Int and Uint types. +const MaxBitLen = 256 func newIntegerFromString(s string) (*big.Int, bool) { return new(big.Int).SetString(s, 0) @@ -59,7 +60,7 @@ func unmarshalText(i *big.Int, text string) error { return err } - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { return fmt.Errorf("integer out of range: %s", text) } @@ -107,7 +108,7 @@ func NewIntFromBigInt(i *big.Int) Int { return Int{} } - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { panic("NewIntFromBigInt() out of bound") } return Int{i} @@ -120,7 +121,7 @@ func NewIntFromString(s string) (res Int, ok bool) { return } // Check overflow - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { ok = false return } @@ -138,7 +139,7 @@ func NewIntWithDecimal(n int64, dec int) Int { i.Mul(big.NewInt(n), exp) // Check overflow - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { panic("NewIntWithDecimal() out of bound") } return Int{i} @@ -228,7 +229,7 @@ func (i Int) LTE(i2 Int) bool { func (i Int) Add(i2 Int) (res Int) { res = Int{add(i.i, i2.i)} // Check overflow - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -243,7 +244,7 @@ func (i Int) AddRaw(i2 int64) Int { func (i Int) Sub(i2 Int) (res Int) { res = Int{sub(i.i, i2.i)} // Check overflow - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -257,12 +258,12 @@ func (i Int) SubRaw(i2 int64) Int { // Mul multiples two Ints func (i Int) Mul(i2 Int) (res Int) { // Check overflow - if i.i.BitLen()+i2.i.BitLen()-1 > maxBitLen { + if i.i.BitLen()+i2.i.BitLen()-1 > MaxBitLen { panic("Int overflow") } res = Int{mul(i.i, i2.i)} // Check overflow if sign of both are same - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -410,8 +411,8 @@ func (i *Int) Unmarshal(data []byte) error { return err } - if i.i.BitLen() > maxBitLen { - return fmt.Errorf("integer out of range; got: %d, max: %d", i.i.BitLen(), maxBitLen) + if i.i.BitLen() > MaxBitLen { + return fmt.Errorf("integer out of range; got: %d, max: %d", i.i.BitLen(), MaxBitLen) } return nil diff --git a/math/uint.go b/math/uint.go index d5842f206e42..505984d19864 100644 --- a/math/uint.go +++ b/math/uint.go @@ -190,8 +190,8 @@ func (u *Uint) Unmarshal(data []byte) error { return err } - if u.i.BitLen() > maxBitLen { - return fmt.Errorf("integer out of range; got: %d, max: %d", u.i.BitLen(), maxBitLen) + if u.i.BitLen() > MaxBitLen { + return fmt.Errorf("integer out of range; got: %d, max: %d", u.i.BitLen(), MaxBitLen) } return nil diff --git a/server/rosetta/converter.go b/server/rosetta/converter.go index 6782073aaff6..841d1407a0ba 100644 --- a/server/rosetta/converter.go +++ b/server/rosetta/converter.go @@ -18,6 +18,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors" crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -420,7 +421,7 @@ func (c converter) Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*r value, owned := ownedCoinsMap[coin.Denom] if !owned { amounts[i] = &rosettatypes.Amount{ - Value: sdk.NewInt(0).String(), + Value: sdkmath.NewInt(0).String(), Currency: &rosettatypes.Currency{ Symbol: coin.Denom, }, diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 858997d0caf2..0254828f89c6 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/testutil" @@ -299,7 +300,7 @@ func initTestnetFiles( sdk.NewCoin(sdk.DefaultBondDenom, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + sdkmath.OneInt(), ) if err != nil { return err diff --git a/simapp/state.go b/simapp/state.go index f888a45bcd8b..b8d4fd612fc0 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdkmath "github.com/cosmos/cosmos-sdk/math" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -88,7 +89,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty panic(err) } // compute not bonded balance - notBondedTokens := sdk.ZeroInt() + notBondedTokens := sdkmath.ZeroInt() for _, val := range stakingState.Validators { if val.Status != stakingtypes.Unbonded { continue diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 4fe0c2b4d87f..c51db38c6ad4 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/simapp/params" @@ -93,7 +94,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := NewSimApp(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.EncConfig, options.AppOpts) @@ -135,7 +136,7 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp { acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -172,7 +173,7 @@ func genesisStateWithValSet(t *testing.T, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) @@ -275,7 +276,7 @@ func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState { balances := []banktypes.Balance{ { Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), }, } diff --git a/testutil/network/network.go b/testutil/network/network.go index 995eb56889df..a695b5d2d964 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -32,6 +32,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" @@ -401,7 +402,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + sdkmath.OneInt(), ) if err != nil { return nil, err @@ -413,7 +414,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { } memo := fmt.Sprintf("%s@%s:%s", nodeIDs[i], p2pURL.Hostname(), p2pURL.Port()) - fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdk.NewInt(0))) + fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdkmath.NewInt(0))) txBuilder := cfg.TxConfig.NewTxBuilder() err = txBuilder.SetMsgs(createValMsg) if err != nil { diff --git a/types/bench_test.go b/types/bench_test.go index e9ed9fa12bff..049860968a61 100644 --- a/types/bench_test.go +++ b/types/bench_test.go @@ -3,6 +3,7 @@ package types_test import ( "testing" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/types" ) @@ -44,7 +45,7 @@ func BenchmarkUintMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - u := types.NewUint(value) + u := sdkmath.NewUint(value) n, err := u.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) @@ -69,7 +70,7 @@ func BenchmarkIntMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - in := types.NewInt(value) + in := sdkmath.NewInt(value) n, err := in.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) diff --git a/types/coin.go b/types/coin.go index 1b8e465c1d81..7537720756e4 100644 --- a/types/coin.go +++ b/types/coin.go @@ -6,6 +6,8 @@ import ( "regexp" "sort" "strings" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) //----------------------------------------------------------------------------- @@ -29,7 +31,7 @@ func NewCoin(denom string, amount Int) Coin { // NewInt64Coin returns a new coin with a denomination and amount. It will panic // if the amount is negative. func NewInt64Coin(denom string, amount int64) Coin { - return NewCoin(denom, NewInt(amount)) + return NewCoin(denom, sdkmath.NewInt(amount)) } // String provides a human-readable representation of a coin @@ -166,7 +168,7 @@ func (coin Coin) IsNegative() bool { // IsNil returns true if the coin amount is nil and false otherwise. func (coin Coin) IsNil() bool { - return coin.Amount.i == nil + return coin.Amount.BigInt() == nil } //----------------------------------------------------------------------------- @@ -640,14 +642,14 @@ func (coins Coins) AmountOf(denom string) Int { func (coins Coins) AmountOfNoDenomValidation(denom string) Int { switch len(coins) { case 0: - return ZeroInt() + return sdkmath.ZeroInt() case 1: coin := coins[0] if coin.Denom == denom { return coin.Amount } - return ZeroInt() + return sdkmath.ZeroInt() default: // Binary search the amount of coins remaining diff --git a/types/coin_benchmark_test.go b/types/coin_benchmark_test.go index 9730284c9b3d..ba0256630041 100644 --- a/types/coin_benchmark_test.go +++ b/types/coin_benchmark_test.go @@ -3,6 +3,8 @@ package types import ( "fmt" "testing" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) func coinName(suffix int) string { @@ -18,10 +20,10 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) { coinsB := Coins(make([]Coin, numCoinsB)) for i := 0; i < numCoinsA; i++ { - coinsA[i] = NewCoin(coinName(i), NewInt(int64(i))) + coinsA[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) } for i := 0; i < numCoinsB; i++ { - coinsB[i] = NewCoin(coinName(i), NewInt(int64(i))) + coinsB[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) } b.ResetTimer() @@ -49,10 +51,10 @@ func BenchmarkCoinsAdditionNoIntersect(b *testing.B) { coinsB := Coins(make([]Coin, numCoinsB)) for i := 0; i < numCoinsA; i++ { - coinsA[i] = NewCoin(coinName(numCoinsB+i), NewInt(int64(i))) + coinsA[i] = NewCoin(coinName(numCoinsB+i), sdkmath.NewInt(int64(i))) } for i := 0; i < numCoinsB; i++ { - coinsB[i] = NewCoin(coinName(i), NewInt(int64(i))) + coinsB[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) } b.ResetTimer() diff --git a/types/coin_internal_test.go b/types/coin_internal_test.go index 709683795c37..b20942262153 100644 --- a/types/coin_internal_test.go +++ b/types/coin_internal_test.go @@ -4,6 +4,8 @@ import ( "testing" "github.com/stretchr/testify/suite" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) func TestCoinTestSuite(t *testing.T) { @@ -15,7 +17,7 @@ type coinInternalSuite struct { } func (s *coinInternalSuite) TestIsSorted() { - v := NewInt(1) + v := sdkmath.NewInt(1) cases := []struct { coins Coins expected bool diff --git a/types/coin_test.go b/types/coin_test.go index 64a39c813e09..d58a0400d323 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -27,9 +28,9 @@ func TestCoinTestSuite(t *testing.T) { func (s *coinTestSuite) SetupSuite() { s.T().Parallel() - zero := sdk.NewInt(0) - one := sdk.OneInt() - two := sdk.NewInt(2) + zero := sdkmath.NewInt(0) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.ca0, s.ca1, s.ca2 = sdk.Coin{testDenom1, zero}, sdk.Coin{testDenom1, one}, sdk.Coin{testDenom1, two} s.cm0, s.cm1, s.cm2 = sdk.Coin{testDenom2, zero}, sdk.Coin{testDenom2, one}, sdk.Coin{testDenom2, two} } @@ -39,15 +40,15 @@ func (s *coinTestSuite) SetupSuite() { func (s *coinTestSuite) TestCoin() { s.Require().Panics(func() { sdk.NewInt64Coin(testDenom1, -1) }) - s.Require().Panics(func() { sdk.NewCoin(testDenom1, sdk.NewInt(-1)) }) - s.Require().Equal(sdk.NewInt(10), sdk.NewInt64Coin(strings.ToUpper(testDenom1), 10).Amount) - s.Require().Equal(sdk.NewInt(10), sdk.NewCoin(strings.ToUpper(testDenom1), sdk.NewInt(10)).Amount) - s.Require().Equal(sdk.NewInt(5), sdk.NewInt64Coin(testDenom1, 5).Amount) - s.Require().Equal(sdk.NewInt(5), sdk.NewCoin(testDenom1, sdk.NewInt(5)).Amount) + s.Require().Panics(func() { sdk.NewCoin(testDenom1, sdkmath.NewInt(-1)) }) + s.Require().Equal(sdkmath.NewInt(10), sdk.NewInt64Coin(strings.ToUpper(testDenom1), 10).Amount) + s.Require().Equal(sdkmath.NewInt(10), sdk.NewCoin(strings.ToUpper(testDenom1), sdkmath.NewInt(10)).Amount) + s.Require().Equal(sdkmath.NewInt(5), sdk.NewInt64Coin(testDenom1, 5).Amount) + s.Require().Equal(sdkmath.NewInt(5), sdk.NewCoin(testDenom1, sdkmath.NewInt(5)).Amount) } func (s *coinTestSuite) TestCoin_String() { - coin := sdk.NewCoin(testDenom1, sdk.NewInt(10)) + coin := sdk.NewCoin(testDenom1, sdkmath.NewInt(10)) s.Require().Equal(fmt.Sprintf("10%s", testDenom1), coin.String()) } @@ -87,17 +88,17 @@ func (s *coinTestSuite) TestCoinIsValid() { coin sdk.Coin expectPass bool }{ - {sdk.Coin{testDenom1, sdk.NewInt(-1)}, false}, - {sdk.Coin{testDenom1, sdk.NewInt(0)}, true}, - {sdk.Coin{testDenom1, sdk.OneInt()}, true}, - {sdk.Coin{"Atom", sdk.OneInt()}, true}, - {sdk.Coin{"ATOM", sdk.OneInt()}, true}, - {sdk.Coin{"a", sdk.OneInt()}, false}, - {sdk.Coin{loremIpsum, sdk.OneInt()}, false}, - {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, true}, - {sdk.Coin{"atOm", sdk.OneInt()}, true}, - {sdk.Coin{"x:y-z.1_2", sdk.OneInt()}, true}, - {sdk.Coin{" ", sdk.OneInt()}, false}, + {sdk.Coin{testDenom1, sdkmath.NewInt(-1)}, false}, + {sdk.Coin{testDenom1, sdkmath.NewInt(0)}, true}, + {sdk.Coin{testDenom1, sdkmath.OneInt()}, true}, + {sdk.Coin{"Atom", sdkmath.OneInt()}, true}, + {sdk.Coin{"ATOM", sdkmath.OneInt()}, true}, + {sdk.Coin{"a", sdkmath.OneInt()}, false}, + {sdk.Coin{loremIpsum, sdkmath.OneInt()}, false}, + {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.OneInt()}, true}, + {sdk.Coin{"atOm", sdkmath.OneInt()}, true}, + {sdk.Coin{"x:y-z.1_2", sdkmath.OneInt()}, true}, + {sdk.Coin{" ", sdkmath.OneInt()}, false}, } for i, tc := range cases { @@ -116,11 +117,11 @@ func (s *coinTestSuite) TestCustomValidation() { coin sdk.Coin expectPass bool }{ - {sdk.Coin{"🙂", sdk.NewInt(1)}, true}, - {sdk.Coin{"🙁", sdk.NewInt(1)}, true}, - {sdk.Coin{"🌶", sdk.NewInt(1)}, false}, // outside the unicode range listed above - {sdk.Coin{"asdf", sdk.NewInt(1)}, false}, - {sdk.Coin{"", sdk.NewInt(1)}, false}, + {sdk.Coin{"🙂", sdkmath.NewInt(1)}, true}, + {sdk.Coin{"🙁", sdkmath.NewInt(1)}, true}, + {sdk.Coin{"🌶", sdkmath.NewInt(1)}, false}, // outside the unicode range listed above + {sdk.Coin{"asdf", sdkmath.NewInt(1)}, false}, + {sdk.Coin{"", sdkmath.NewInt(1)}, false}, } for i, tc := range cases { @@ -158,8 +159,8 @@ func (s *coinTestSuite) TestAddCoinAmount() { amount sdk.Int expected sdk.Coin }{ - {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 2)}, - {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(0), sdk.NewInt64Coin(testDenom1, 1)}, + {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 2)}, + {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(0), sdk.NewInt64Coin(testDenom1, 1)}, } for i, tc := range cases { res := tc.coin.AddAmount(tc.amount) @@ -207,11 +208,11 @@ func (s *coinTestSuite) TestSubCoinAmount() { expected sdk.Coin shouldPanic bool }{ - {sdk.NewInt64Coin(testDenom1, 2), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 1), false}, - {sdk.NewInt64Coin(testDenom1, 10), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 9), false}, - {sdk.NewInt64Coin(testDenom1, 5), sdk.NewInt(3), sdk.NewInt64Coin(testDenom1, 2), false}, - {sdk.NewInt64Coin(testDenom1, 5), sdk.NewInt(0), sdk.NewInt64Coin(testDenom1, 5), false}, - {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(5), sdk.Coin{}, true}, + {sdk.NewInt64Coin(testDenom1, 2), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 1), false}, + {sdk.NewInt64Coin(testDenom1, 10), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 9), false}, + {sdk.NewInt64Coin(testDenom1, 5), sdkmath.NewInt(3), sdk.NewInt64Coin(testDenom1, 2), false}, + {sdk.NewInt64Coin(testDenom1, 5), sdkmath.NewInt(0), sdk.NewInt64Coin(testDenom1, 5), false}, + {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(5), sdk.Coin{}, true}, } for i, tc := range cases { @@ -332,11 +333,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "all greater than zero", input: sdk.Coins{ - {"testa", sdk.OneInt()}, - {"testb", sdk.NewInt(2)}, - {"testc", sdk.NewInt(3)}, - {"testd", sdk.NewInt(4)}, - {"teste", sdk.NewInt(5)}, + {"testa", sdkmath.OneInt()}, + {"testb", sdkmath.NewInt(2)}, + {"testc", sdkmath.NewInt(3)}, + {"testd", sdkmath.NewInt(4)}, + {"teste", sdkmath.NewInt(5)}, }, original: "1testa,2testb,3testc,4testd,5teste", expected: "1testa,2testb,3testc,4testd,5teste", @@ -344,11 +345,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "zero coin in middle", input: sdk.Coins{ - {"testa", sdk.OneInt()}, - {"testb", sdk.NewInt(2)}, - {"testc", sdk.NewInt(0)}, - {"testd", sdk.NewInt(4)}, - {"teste", sdk.NewInt(5)}, + {"testa", sdkmath.OneInt()}, + {"testb", sdkmath.NewInt(2)}, + {"testc", sdkmath.NewInt(0)}, + {"testd", sdkmath.NewInt(4)}, + {"teste", sdkmath.NewInt(5)}, }, original: "1testa,2testb,0testc,4testd,5teste", expected: "1testa,2testb,4testd,5teste", @@ -356,11 +357,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "zero coin end (unordered)", input: sdk.Coins{ - {"teste", sdk.NewInt(5)}, - {"testc", sdk.NewInt(3)}, - {"testa", sdk.OneInt()}, - {"testd", sdk.NewInt(4)}, - {"testb", sdk.NewInt(0)}, + {"teste", sdkmath.NewInt(5)}, + {"testc", sdkmath.NewInt(3)}, + {"testa", sdkmath.OneInt()}, + {"testd", sdkmath.NewInt(4)}, + {"testb", sdkmath.NewInt(0)}, }, original: "5teste,3testc,1testa,4testd,0testb", expected: "1testa,3testc,4testd,5teste", @@ -390,15 +391,15 @@ func (s *coinTestSuite) TestCoins_String() { }, { "single coin", - sdk.Coins{{"tree", sdk.OneInt()}}, + sdk.Coins{{"tree", sdkmath.OneInt()}}, "1tree", }, { "multiple coins", sdk.Coins{ - {"tree", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"tree", sdkmath.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, "1tree,1gas,1mineral", }, @@ -538,88 +539,88 @@ func (s *coinTestSuite) TestCoins_Validate() { { "valid lowercase coins", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, - {"tree", sdk.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, + {"tree", sdkmath.OneInt()}, }, true, }, { "valid uppercase coins", sdk.Coins{ - {"GAS", sdk.OneInt()}, - {"MINERAL", sdk.OneInt()}, - {"TREE", sdk.OneInt()}, + {"GAS", sdkmath.OneInt()}, + {"MINERAL", sdkmath.OneInt()}, + {"TREE", sdkmath.OneInt()}, }, true, }, { "valid uppercase coin", sdk.Coins{ - {"ATOM", sdk.OneInt()}, + {"ATOM", sdkmath.OneInt()}, }, true, }, { "valid lower and uppercase coins (1)", sdk.Coins{ - {"GAS", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"GAS", sdkmath.OneInt()}, + {"gAs", sdkmath.OneInt()}, }, true, }, { "valid lower and uppercase coins (2)", sdk.Coins{ - {"ATOM", sdk.OneInt()}, - {"Atom", sdk.OneInt()}, - {"atom", sdk.OneInt()}, + {"ATOM", sdkmath.OneInt()}, + {"Atom", sdkmath.OneInt()}, + {"atom", sdkmath.OneInt()}, }, true, }, { "mixed case (1)", sdk.Coins{ - {"MineraL", sdk.OneInt()}, - {"TREE", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"MineraL", sdkmath.OneInt()}, + {"TREE", sdkmath.OneInt()}, + {"gAs", sdkmath.OneInt()}, }, true, }, { "mixed case (2)", sdk.Coins{ - {"gAs", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gAs", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, true, }, { "mixed case (3)", sdk.Coins{ - {"gAs", sdk.OneInt()}, + {"gAs", sdkmath.OneInt()}, }, true, }, { "unicode letters and numbers", sdk.Coins{ - {"𐀀𐀆𐀉Ⅲ", sdk.OneInt()}, + {"𐀀𐀆𐀉Ⅲ", sdkmath.OneInt()}, }, false, }, { "emojis", sdk.Coins{ - {"🤑😋🤔", sdk.OneInt()}, + {"🤑😋🤔", sdkmath.OneInt()}, }, false, }, { "IBC denominations (ADR 001)", sdk.Coins{ - {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, - {"ibc/876563AAAACF739EB061C67CDB5EDF2B7C9FD4AA9D876450CC21210807C2820A", sdk.NewInt(2)}, + {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.OneInt()}, + {"ibc/876563AAAACF739EB061C67CDB5EDF2B7C9FD4AA9D876450CC21210807C2820A", sdkmath.NewInt(2)}, }, true, }, @@ -636,61 +637,61 @@ func (s *coinTestSuite) TestCoins_Validate() { { "invalid denomination (1)", sdk.Coins{ - {"MineraL", sdk.OneInt()}, - {"0TREE", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"MineraL", sdkmath.OneInt()}, + {"0TREE", sdkmath.OneInt()}, + {"gAs", sdkmath.OneInt()}, }, false, }, { "invalid denomination (2)", sdk.Coins{ - {"-GAS", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"-GAS", sdkmath.OneInt()}, + {"gAs", sdkmath.OneInt()}, }, false, }, { "bad sort (1)", sdk.Coins{ - {"tree", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"tree", sdkmath.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, false, }, { "bad sort (2)", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"tree", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"tree", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, false, }, { "non-positive amount (1)", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"tree", sdk.NewInt(0)}, - {"mineral", sdk.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"tree", sdkmath.NewInt(0)}, + {"mineral", sdkmath.OneInt()}, }, false, }, { "non-positive amount (2)", sdk.Coins{ - {"gas", sdk.NewInt(-1)}, - {"tree", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gas", sdkmath.NewInt(-1)}, + {"tree", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, false, }, { "duplicate denomination", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"gas", sdkmath.OneInt()}, + {"mineral", sdkmath.OneInt()}, }, false, }, @@ -707,8 +708,8 @@ func (s *coinTestSuite) TestCoins_Validate() { } func (s *coinTestSuite) TestMinMax() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) cases := []struct { name string @@ -734,8 +735,8 @@ func (s *coinTestSuite) TestMinMax() { } func (s *coinTestSuite) TestCoinsGT() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGT(sdk.Coins{})) @@ -746,8 +747,8 @@ func (s *coinTestSuite) TestCoinsGT() { } func (s *coinTestSuite) TestCoinsLT() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().False(sdk.Coins{}.IsAllLT(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAllLT(sdk.Coins{})) @@ -761,8 +762,8 @@ func (s *coinTestSuite) TestCoinsLT() { } func (s *coinTestSuite) TestCoinsLTE() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().True(sdk.Coins{}.IsAllLTE(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAllLTE(sdk.Coins{})) @@ -776,7 +777,7 @@ func (s *coinTestSuite) TestCoinsLTE() { } func (s *coinTestSuite) TestParseCoins() { - one := sdk.OneInt() + one := sdkmath.OneInt() cases := []struct { input string @@ -785,22 +786,22 @@ func (s *coinTestSuite) TestParseCoins() { }{ {"", true, nil}, {"0stake", true, sdk.Coins{}}, // remove zero coins - {"0stake,1foo,99bar", true, sdk.Coins{{"bar", sdk.NewInt(99)}, {"foo", one}}}, // remove zero coins + {"0stake,1foo,99bar", true, sdk.Coins{{"bar", sdkmath.NewInt(99)}, {"foo", one}}}, // remove zero coins {"1foo", true, sdk.Coins{{"foo", one}}}, {"10btc,1atom,20btc", false, nil}, - {"10bar", true, sdk.Coins{{"bar", sdk.NewInt(10)}}}, - {"99bar,1foo", true, sdk.Coins{{"bar", sdk.NewInt(99)}, {"foo", one}}}, - {"98 bar , 1 foo ", true, sdk.Coins{{"bar", sdk.NewInt(98)}, {"foo", one}}}, - {" 55\t \t bling\n", true, sdk.Coins{{"bling", sdk.NewInt(55)}}}, - {"2foo, 97 bar", true, sdk.Coins{{"bar", sdk.NewInt(97)}, {"foo", sdk.NewInt(2)}}}, - {"5 mycoin,", false, nil}, // no empty coins in a list - {"2 3foo, 97 bar", false, nil}, // 3foo is invalid coin name - {"11me coin, 12you coin", false, nil}, // no spaces in coin names - {"1.2btc", true, sdk.Coins{{"btc", sdk.NewInt(1)}}}, // amount can be decimal, will get truncated - {"5foo:bar", true, sdk.Coins{{"foo:bar", sdk.NewInt(5)}}}, - {"10atom10", true, sdk.Coins{{"atom10", sdk.NewInt(10)}}}, - {"200transfer/channelToA/uatom", true, sdk.Coins{{"transfer/channelToA/uatom", sdk.NewInt(200)}}}, - {"50ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", true, sdk.Coins{{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.NewInt(50)}}}, + {"10bar", true, sdk.Coins{{"bar", sdkmath.NewInt(10)}}}, + {"99bar,1foo", true, sdk.Coins{{"bar", sdkmath.NewInt(99)}, {"foo", one}}}, + {"98 bar , 1 foo ", true, sdk.Coins{{"bar", sdkmath.NewInt(98)}, {"foo", one}}}, + {" 55\t \t bling\n", true, sdk.Coins{{"bling", sdkmath.NewInt(55)}}}, + {"2foo, 97 bar", true, sdk.Coins{{"bar", sdkmath.NewInt(97)}, {"foo", sdkmath.NewInt(2)}}}, + {"5 mycoin,", false, nil}, // no empty coins in a list + {"2 3foo, 97 bar", false, nil}, // 3foo is invalid coin name + {"11me coin, 12you coin", false, nil}, // no spaces in coin names + {"1.2btc", true, sdk.Coins{{"btc", sdkmath.NewInt(1)}}}, // amount can be decimal, will get truncated + {"5foo:bar", true, sdk.Coins{{"foo:bar", sdkmath.NewInt(5)}}}, + {"10atom10", true, sdk.Coins{{"atom10", sdkmath.NewInt(10)}}}, + {"200transfer/channelToA/uatom", true, sdk.Coins{{"transfer/channelToA/uatom", sdkmath.NewInt(200)}}}, + {"50ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", true, sdk.Coins{{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.NewInt(50)}}}, } for tcIndex, tc := range cases { @@ -910,17 +911,17 @@ func (s *coinTestSuite) TestAmountOf() { } for _, tc := range cases { - s.Require().Equal(sdk.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas")) - s.Require().Equal(sdk.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral")) - s.Require().Equal(sdk.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree")) + s.Require().Equal(sdkmath.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas")) + s.Require().Equal(sdkmath.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral")) + s.Require().Equal(sdkmath.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree")) } s.Require().Panics(func() { cases[0].coins.AmountOf("10Invalid") }) } func (s *coinTestSuite) TestCoinsIsAnyGTE() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().False(sdk.Coins{}.IsAnyGTE(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAnyGTE(sdk.Coins{})) @@ -939,8 +940,8 @@ func (s *coinTestSuite) TestCoinsIsAnyGTE() { } func (s *coinTestSuite) TestCoinsIsAllGT() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGT(sdk.Coins{})) @@ -959,8 +960,8 @@ func (s *coinTestSuite) TestCoinsIsAllGT() { } func (s *coinTestSuite) TestCoinsIsAllGTE() { - one := sdk.OneInt() - two := sdk.NewInt(2) + one := sdkmath.OneInt() + two := sdkmath.NewInt(2) s.Require().True(sdk.Coins{}.IsAllGTE(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGTE(sdk.Coins{})) @@ -984,7 +985,7 @@ func (s *coinTestSuite) TestNewCoins() { tenatom := sdk.NewInt64Coin("atom", 10) tenbtc := sdk.NewInt64Coin("btc", 10) zeroeth := sdk.NewInt64Coin("eth", 0) - invalidCoin := sdk.Coin{"0ETH", sdk.OneInt()} + invalidCoin := sdk.Coin{"0ETH", sdkmath.OneInt()} tests := []struct { name string coins sdk.Coins diff --git a/types/dec_coin.go b/types/dec_coin.go index aebfcc12192c..2866fd51e7a3 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/pkg/errors" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) // ---------------------------------------------------------------------------- @@ -17,7 +19,7 @@ func NewDecCoin(denom string, amount Int) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: coin.Amount.ToDec(), + Amount: ToDec(coin.Amount), } } @@ -43,14 +45,14 @@ func NewDecCoinFromCoin(coin Coin) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: coin.Amount.ToDec(), + Amount: ToDec(coin.Amount), } } // NewInt64DecCoin returns a new DecCoin with a denomination and amount. It will // panic if the amount is negative or denom is invalid. func NewInt64DecCoin(denom string, amount int64) DecCoin { - return NewDecCoin(denom, NewInt(amount)) + return NewDecCoin(denom, sdkmath.NewInt(amount)) } // IsZero returns if the DecCoin amount is zero. @@ -111,7 +113,7 @@ func (coin DecCoin) Sub(coinB DecCoin) DecCoin { // change. Note, the change may be zero. func (coin DecCoin) TruncateDecimal() (Coin, DecCoin) { truncated := coin.Amount.TruncateInt() - change := coin.Amount.Sub(truncated.ToDec()) + change := coin.Amount.Sub(ToDec(truncated)) return NewCoin(coin.Denom, truncated), NewDecCoinFromDec(coin.Denom, change) } diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index 52f50d24fc22..d46ba1c8df11 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -49,16 +50,16 @@ func (s *decCoinTestSuite) TestNewDecCoinFromDec() { func (s *decCoinTestSuite) TestNewDecCoinFromCoin() { s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(5)}) }) s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(0)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(0)}) }) s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{strings.ToUpper(testDenom1), sdk.NewInt(5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{strings.ToUpper(testDenom1), sdkmath.NewInt(5)}) }) s.Require().Panics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(-5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(-5)}) }) } @@ -187,7 +188,7 @@ func (s *decCoinTestSuite) TestIsValid() { msg string }{ { - sdk.NewDecCoin("mytoken", sdk.NewInt(10)), + sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)), true, "valid coins should have passed", }, @@ -225,23 +226,23 @@ func (s *decCoinTestSuite) TestSubDecCoin() { msg string }{ { - sdk.NewDecCoin("mytoken", sdk.NewInt(20)), + sdk.NewDecCoin("mytoken", sdkmath.NewInt(20)), true, "valid coins should have passed", }, { - sdk.NewDecCoin("othertoken", sdk.NewInt(20)), + sdk.NewDecCoin("othertoken", sdkmath.NewInt(20)), false, "denom mismatch", }, { - sdk.NewDecCoin("mytoken", sdk.NewInt(9)), + sdk.NewDecCoin("mytoken", sdkmath.NewInt(9)), false, "negative amount", }, } - decCoin := sdk.NewDecCoin("mytoken", sdk.NewInt(10)) + decCoin := sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)) for _, tc := range tests { tc := tc @@ -261,23 +262,23 @@ func (s *decCoinTestSuite) TestSubDecCoins() { msg string }{ { - sdk.NewDecCoinsFromCoins(sdk.NewCoin("mytoken", sdk.NewInt(10)), sdk.NewCoin("btc", sdk.NewInt(20)), sdk.NewCoin("eth", sdk.NewInt(30))), + sdk.NewDecCoinsFromCoins(sdk.NewCoin("mytoken", sdkmath.NewInt(10)), sdk.NewCoin("btc", sdkmath.NewInt(20)), sdk.NewCoin("eth", sdkmath.NewInt(30))), true, "sorted coins should have passed", }, { - sdk.DecCoins{sdk.NewDecCoin("mytoken", sdk.NewInt(10)), sdk.NewDecCoin("btc", sdk.NewInt(20)), sdk.NewDecCoin("eth", sdk.NewInt(30))}, + sdk.DecCoins{sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)), sdk.NewDecCoin("btc", sdkmath.NewInt(20)), sdk.NewDecCoin("eth", sdkmath.NewInt(30))}, false, "unorted coins should panic", }, { - sdk.DecCoins{sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}, sdk.NewDecCoin("eth", sdk.NewInt(15)), sdk.NewDecCoin("mytoken", sdk.NewInt(5))}, + sdk.DecCoins{sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}, sdk.NewDecCoin("eth", sdkmath.NewInt(15)), sdk.NewDecCoin("mytoken", sdkmath.NewInt(5))}, false, "invalid denoms", }, } - decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", sdk.NewInt(10)), sdk.NewCoin("eth", sdk.NewInt(15)), sdk.NewCoin("mytoken", sdk.NewInt(5))) + decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", sdkmath.NewInt(10)), sdk.NewCoin("eth", sdkmath.NewInt(15)), sdk.NewCoin("mytoken", sdkmath.NewInt(5))) for _, tc := range tests { tc := tc @@ -374,7 +375,7 @@ func (s *decCoinTestSuite) TestParseDecCoins() { expectedErr bool }{ {"", nil, false}, - {"4stake", sdk.DecCoins{sdk.NewDecCoinFromDec("stake", sdk.NewDecFromInt(sdk.NewInt(4)))}, false}, + {"4stake", sdk.DecCoins{sdk.NewDecCoinFromDec("stake", sdk.NewDecFromInt(sdkmath.NewInt(4)))}, false}, {"5.5atom,4stake", sdk.DecCoins{ sdk.NewDecCoinFromDec("atom", sdk.NewDecWithPrec(5500000000000000000, sdk.Precision)), sdk.NewDecCoinFromDec("stake", sdk.NewDec(4)), @@ -532,8 +533,8 @@ func (s *decCoinTestSuite) TestDecCoinsQuoDecTruncate() { } func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { - fake1 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), sdk.DecCoin{Denom: "10BTC", Amount: sdk.NewDec(10)}) - fake2 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}) + fake1 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), sdk.DecCoin{Denom: "10BTC", Amount: sdk.NewDec(10)}) + fake2 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}) tests := []struct { coin sdk.DecCoins @@ -541,7 +542,7 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { msg string }{ { - sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), + sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), true, "valid coins should have passed", }, @@ -568,7 +569,7 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { } func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { - lengthTestDecCoins := sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}) + lengthTestDecCoins := sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}) s.Require().Equal(2, len(lengthTestDecCoins), "should be 2") tests := []struct { @@ -577,17 +578,17 @@ func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { msg string }{ { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), true, "valid coins should have passed", }, { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "0BTC", Amount: sdk.NewDec(10)}), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "0BTC", Amount: sdk.NewDec(10)}), false, "invalid denoms", }, { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}), false, "negative amount", }, diff --git a/types/decimal.go b/types/decimal.go index f7d7ad9ffe66..65add7371702 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -8,6 +8,8 @@ import ( "strconv" "strings" "testing" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) var _ CustomProtobufType = (*Dec)(nil) @@ -26,7 +28,7 @@ const ( // Ceiling[Log2[999 999 999 999 999 999]] DecimalPrecisionBits = 60 - maxDecBitLen = maxBitLen + DecimalPrecisionBits + maxDecBitLen = sdkmath.MaxBitLen + DecimalPrecisionBits // max number of iterations in ApproxRoot function maxApproxRootIterations = 100 @@ -313,7 +315,7 @@ func (d Dec) MulInt(i Int) Dec { } func (d Dec) MulIntMut(i Int) Dec { - d.i.Mul(d.i, i.i) + d.i.Mul(d.i, i.BigInt()) if d.i.BitLen() > maxDecBitLen { panic("Int overflow") } @@ -397,7 +399,7 @@ func (d Dec) QuoInt(i Int) Dec { } func (d Dec) QuoIntMut(i Int) Dec { - d.i.Quo(d.i, i.i) + d.i.Quo(d.i, i.BigInt()) return d } @@ -652,7 +654,7 @@ func (d Dec) RoundInt64() int64 { // RoundInt round the decimal using bankers rounding func (d Dec) RoundInt() Int { - return NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) + return sdkmath.NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) } // chopPrecisionAndTruncate is similar to chopPrecisionAndRound, @@ -678,7 +680,7 @@ func (d Dec) TruncateInt64() int64 { // TruncateInt truncates the decimals from the number and returns an Int func (d Dec) TruncateInt() Int { - return NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.i)) + return sdkmath.NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.i)) } // TruncateDec truncates the decimals from the number and returns a Dec diff --git a/types/decimal_test.go b/types/decimal_test.go index 742edb60c1e0..cf0dca8fe219 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/suite" "sigs.k8s.io/yaml" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -346,10 +347,10 @@ func (s *decimalTestSuite) TestDecMulInt() { sdkInt sdk.Int want sdk.Dec }{ - {sdk.NewDec(10), sdk.NewInt(2), sdk.NewDec(20)}, - {sdk.NewDec(1000000), sdk.NewInt(100), sdk.NewDec(100000000)}, - {sdk.NewDecWithPrec(1, 1), sdk.NewInt(10), sdk.NewDec(1)}, - {sdk.NewDecWithPrec(1, 5), sdk.NewInt(20), sdk.NewDecWithPrec(2, 4)}, + {sdk.NewDec(10), sdkmath.NewInt(2), sdk.NewDec(20)}, + {sdk.NewDec(1000000), sdkmath.NewInt(100), sdk.NewDec(100000000)}, + {sdk.NewDecWithPrec(1, 1), sdkmath.NewInt(10), sdk.NewDec(1)}, + {sdk.NewDecWithPrec(1, 5), sdkmath.NewInt(20), sdk.NewDecWithPrec(2, 4)}, } for i, tc := range tests { got := tc.sdkDec.MulInt(tc.sdkInt) @@ -384,13 +385,13 @@ func (s *decimalTestSuite) TestPower() { power uint64 expected sdk.Dec }{ - {sdk.NewDec(100), 0, sdk.OneDec()}, // 10 ^ (0) => 1.0 - {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (10) => 1.0 - {sdk.NewDecWithPrec(5, 1), 2, sdk.NewDecWithPrec(25, 2)}, // 0.5 ^ 2 => 0.25 - {sdk.NewDecWithPrec(2, 1), 2, sdk.NewDecWithPrec(4, 2)}, // 0.2 ^ 2 => 0.04 - {sdk.NewDecFromInt(sdk.NewInt(3)), 3, sdk.NewDecFromInt(sdk.NewInt(27))}, // 3 ^ 3 => 27 - {sdk.NewDecFromInt(sdk.NewInt(-3)), 4, sdk.NewDecFromInt(sdk.NewInt(81))}, // -3 ^ 4 = 81 - {sdk.NewDecWithPrec(1414213562373095049, 18), 2, sdk.NewDecFromInt(sdk.NewInt(2))}, // 1.414213562373095049 ^ 2 = 2 + {sdk.NewDec(100), 0, sdk.OneDec()}, // 10 ^ (0) => 1.0 + {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (10) => 1.0 + {sdk.NewDecWithPrec(5, 1), 2, sdk.NewDecWithPrec(25, 2)}, // 0.5 ^ 2 => 0.25 + {sdk.NewDecWithPrec(2, 1), 2, sdk.NewDecWithPrec(4, 2)}, // 0.2 ^ 2 => 0.04 + {sdk.NewDecFromInt(sdkmath.NewInt(3)), 3, sdk.NewDecFromInt(sdkmath.NewInt(27))}, // 3 ^ 3 => 27 + {sdk.NewDecFromInt(sdkmath.NewInt(-3)), 4, sdk.NewDecFromInt(sdkmath.NewInt(81))}, // -3 ^ 4 = 81 + {sdk.NewDecWithPrec(1414213562373095049, 18), 2, sdk.NewDecFromInt(sdkmath.NewInt(2))}, // 1.414213562373095049 ^ 2 = 2 } for i, tc := range testCases { @@ -414,9 +415,9 @@ func (s *decimalTestSuite) TestApproxRoot() { {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (0.1) => 1.0 {sdk.NewDecWithPrec(25, 2), 2, sdk.NewDecWithPrec(5, 1)}, // 0.25 ^ (0.5) => 0.5 {sdk.NewDecWithPrec(4, 2), 2, sdk.NewDecWithPrec(2, 1)}, // 0.04 ^ (0.5) => 0.2 - {sdk.NewDecFromInt(sdk.NewInt(27)), 3, sdk.NewDecFromInt(sdk.NewInt(3))}, // 27 ^ (1/3) => 3 - {sdk.NewDecFromInt(sdk.NewInt(-81)), 4, sdk.NewDecFromInt(sdk.NewInt(-3))}, // -81 ^ (0.25) => -3 - {sdk.NewDecFromInt(sdk.NewInt(2)), 2, sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 ^ (0.5) => 1.414213562373095049 + {sdk.NewDecFromInt(sdkmath.NewInt(27)), 3, sdk.NewDecFromInt(sdkmath.NewInt(3))}, // 27 ^ (1/3) => 3 + {sdk.NewDecFromInt(sdkmath.NewInt(-81)), 4, sdk.NewDecFromInt(sdkmath.NewInt(-3))}, // -81 ^ (0.25) => -3 + {sdk.NewDecFromInt(sdkmath.NewInt(2)), 2, sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 ^ (0.5) => 1.414213562373095049 {sdk.NewDecWithPrec(1005, 3), 31536000, sdk.MustNewDecFromStr("1.000000000158153904")}, // 1.005 ^ (1/31536000) ≈ 1.00000000016 {sdk.SmallestDec(), 2, sdk.NewDecWithPrec(1, 9)}, // 1e-18 ^ (0.5) => 1e-9 {sdk.SmallestDec(), 3, sdk.MustNewDecFromStr("0.000000999999999997")}, // 1e-18 ^ (1/3) => 1e-6 @@ -439,12 +440,12 @@ func (s *decimalTestSuite) TestApproxSqrt() { input sdk.Dec expected sdk.Dec }{ - {sdk.OneDec(), sdk.OneDec()}, // 1.0 => 1.0 - {sdk.NewDecWithPrec(25, 2), sdk.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 - {sdk.NewDecWithPrec(4, 2), sdk.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 - {sdk.NewDecFromInt(sdk.NewInt(9)), sdk.NewDecFromInt(sdk.NewInt(3))}, // 9 => 3 - {sdk.NewDecFromInt(sdk.NewInt(-9)), sdk.NewDecFromInt(sdk.NewInt(-3))}, // -9 => -3 - {sdk.NewDecFromInt(sdk.NewInt(2)), sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 + {sdk.OneDec(), sdk.OneDec()}, // 1.0 => 1.0 + {sdk.NewDecWithPrec(25, 2), sdk.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 + {sdk.NewDecWithPrec(4, 2), sdk.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 + {sdk.NewDecFromInt(sdkmath.NewInt(9)), sdk.NewDecFromInt(sdkmath.NewInt(3))}, // 9 => 3 + {sdk.NewDecFromInt(sdkmath.NewInt(-9)), sdk.NewDecFromInt(sdkmath.NewInt(-3))}, // -9 => -3 + {sdk.NewDecFromInt(sdkmath.NewInt(2)), sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 } for i, tc := range testCases { diff --git a/types/denom.go b/types/denom.go index 0e8d716a2670..bfb2ff30e14b 100644 --- a/types/denom.go +++ b/types/denom.go @@ -75,7 +75,7 @@ func ConvertCoin(coin Coin, denom string) (Coin, error) { return NewCoin(denom, coin.Amount), nil } - return NewCoin(denom, coin.Amount.ToDec().Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil + return NewCoin(denom, ToDec(coin.Amount).Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil } // ConvertDecCoin attempts to convert a decimal coin to a given denomination. If the given diff --git a/types/denom_internal_test.go b/types/denom_internal_test.go index 8c957353ebc7..da800e6ea298 100644 --- a/types/denom_internal_test.go +++ b/types/denom_internal_test.go @@ -4,6 +4,8 @@ import ( "testing" "github.com/stretchr/testify/suite" + + sdkmath "github.com/cosmos/cosmos-sdk/math" ) var ( @@ -56,16 +58,16 @@ func (s *internalDenomTestSuite) TestConvertCoins() { res, err := GetBaseDenom() s.Require().NoError(err) s.Require().Equal(res, natom) - s.Require().Equal(NormalizeCoin(NewCoin(uatom, NewInt(1))), NewCoin(natom, NewInt(1000))) - s.Require().Equal(NormalizeCoin(NewCoin(matom, NewInt(1))), NewCoin(natom, NewInt(1000000))) - s.Require().Equal(NormalizeCoin(NewCoin(atom, NewInt(1))), NewCoin(natom, NewInt(1000000000))) + s.Require().Equal(NormalizeCoin(NewCoin(uatom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000))) + s.Require().Equal(NormalizeCoin(NewCoin(matom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000000))) + s.Require().Equal(NormalizeCoin(NewCoin(atom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000000000))) coins, err := ParseCoinsNormalized("1atom,1matom,1uatom") s.Require().NoError(err) s.Require().Equal(coins, Coins{ - Coin{natom, NewInt(1000000000)}, - Coin{natom, NewInt(1000000)}, - Coin{natom, NewInt(1000)}, + Coin{natom, sdkmath.NewInt(1000000000)}, + Coin{natom, sdkmath.NewInt(1000000)}, + Coin{natom, sdkmath.NewInt(1000)}, }) testCases := []struct { @@ -74,20 +76,20 @@ func (s *internalDenomTestSuite) TestConvertCoins() { result Coin expErr bool }{ - {NewCoin("foo", ZeroInt()), atom, Coin{}, true}, - {NewCoin(atom, ZeroInt()), "foo", Coin{}, true}, - {NewCoin(atom, ZeroInt()), "FOO", Coin{}, true}, + {NewCoin("foo", sdkmath.ZeroInt()), atom, Coin{}, true}, + {NewCoin(atom, sdkmath.ZeroInt()), "foo", Coin{}, true}, + {NewCoin(atom, sdkmath.ZeroInt()), "FOO", Coin{}, true}, - {NewCoin(atom, NewInt(5)), matom, NewCoin(matom, NewInt(5000)), false}, // atom => matom - {NewCoin(atom, NewInt(5)), uatom, NewCoin(uatom, NewInt(5000000)), false}, // atom => uatom - {NewCoin(atom, NewInt(5)), natom, NewCoin(natom, NewInt(5000000000)), false}, // atom => natom + {NewCoin(atom, sdkmath.NewInt(5)), matom, NewCoin(matom, sdkmath.NewInt(5000)), false}, // atom => matom + {NewCoin(atom, sdkmath.NewInt(5)), uatom, NewCoin(uatom, sdkmath.NewInt(5000000)), false}, // atom => uatom + {NewCoin(atom, sdkmath.NewInt(5)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // atom => natom - {NewCoin(uatom, NewInt(5000000)), matom, NewCoin(matom, NewInt(5000)), false}, // uatom => matom - {NewCoin(uatom, NewInt(5000000)), natom, NewCoin(natom, NewInt(5000000000)), false}, // uatom => natom - {NewCoin(uatom, NewInt(5000000)), atom, NewCoin(atom, NewInt(5)), false}, // uatom => atom + {NewCoin(uatom, sdkmath.NewInt(5000000)), matom, NewCoin(matom, sdkmath.NewInt(5000)), false}, // uatom => matom + {NewCoin(uatom, sdkmath.NewInt(5000000)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // uatom => natom + {NewCoin(uatom, sdkmath.NewInt(5000000)), atom, NewCoin(atom, sdkmath.NewInt(5)), false}, // uatom => atom - {NewCoin(matom, NewInt(5000)), natom, NewCoin(natom, NewInt(5000000000)), false}, // matom => natom - {NewCoin(matom, NewInt(5000)), uatom, NewCoin(uatom, NewInt(5000000)), false}, // matom => uatom + {NewCoin(matom, sdkmath.NewInt(5000)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // matom => natom + {NewCoin(matom, sdkmath.NewInt(5000)), uatom, NewCoin(uatom, sdkmath.NewInt(5000000)), false}, // matom => uatom } for i, tc := range testCases { @@ -123,16 +125,16 @@ func (s *internalDenomTestSuite) TestConvertDecCoins() { res, err := GetBaseDenom() s.Require().NoError(err) s.Require().Equal(res, natom) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(uatom, NewInt(1))), NewDecCoin(natom, NewInt(1000))) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(matom, NewInt(1))), NewDecCoin(natom, NewInt(1000000))) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(atom, NewInt(1))), NewDecCoin(natom, NewInt(1000000000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(uatom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(matom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(atom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000000000))) coins, err := ParseCoinsNormalized("0.1atom,0.1matom,0.1uatom") s.Require().NoError(err) s.Require().Equal(coins, Coins{ - Coin{natom, NewInt(100000000)}, - Coin{natom, NewInt(100000)}, - Coin{natom, NewInt(100)}, + Coin{natom, sdkmath.NewInt(100000000)}, + Coin{natom, sdkmath.NewInt(100000)}, + Coin{natom, sdkmath.NewInt(100)}, }) testCases := []struct { @@ -141,21 +143,21 @@ func (s *internalDenomTestSuite) TestConvertDecCoins() { result DecCoin expErr bool }{ - {NewDecCoin("foo", ZeroInt()), atom, DecCoin{}, true}, - {NewDecCoin(atom, ZeroInt()), "foo", DecCoin{}, true}, - {NewDecCoin(atom, ZeroInt()), "FOO", DecCoin{}, true}, + {NewDecCoin("foo", sdkmath.ZeroInt()), atom, DecCoin{}, true}, + {NewDecCoin(atom, sdkmath.ZeroInt()), "foo", DecCoin{}, true}, + {NewDecCoin(atom, sdkmath.ZeroInt()), "FOO", DecCoin{}, true}, // 0.5atom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), matom, NewDecCoin(matom, NewInt(500)), false}, // atom => matom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), uatom, NewDecCoin(uatom, NewInt(500000)), false}, // atom => uatom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), natom, NewDecCoin(natom, NewInt(500000000)), false}, // atom => natom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), matom, NewDecCoin(matom, sdkmath.NewInt(500)), false}, // atom => matom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), uatom, NewDecCoin(uatom, sdkmath.NewInt(500000)), false}, // atom => uatom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), natom, NewDecCoin(natom, sdkmath.NewInt(500000000)), false}, // atom => natom - {NewDecCoin(uatom, NewInt(5000000)), matom, NewDecCoin(matom, NewInt(5000)), false}, // uatom => matom - {NewDecCoin(uatom, NewInt(5000000)), natom, NewDecCoin(natom, NewInt(5000000000)), false}, // uatom => natom - {NewDecCoin(uatom, NewInt(5000000)), atom, NewDecCoin(atom, NewInt(5)), false}, // uatom => atom + {NewDecCoin(uatom, sdkmath.NewInt(5000000)), matom, NewDecCoin(matom, sdkmath.NewInt(5000)), false}, // uatom => matom + {NewDecCoin(uatom, sdkmath.NewInt(5000000)), natom, NewDecCoin(natom, sdkmath.NewInt(5000000000)), false}, // uatom => natom + {NewDecCoin(uatom, sdkmath.NewInt(5000000)), atom, NewDecCoin(atom, sdkmath.NewInt(5)), false}, // uatom => atom - {NewDecCoin(matom, NewInt(5000)), natom, NewDecCoin(natom, NewInt(5000000000)), false}, // matom => natom - {NewDecCoin(matom, NewInt(5000)), uatom, NewDecCoin(uatom, NewInt(5000000)), false}, // matom => uatom + {NewDecCoin(matom, sdkmath.NewInt(5000)), natom, NewDecCoin(natom, sdkmath.NewInt(5000000000)), false}, // matom => natom + {NewDecCoin(matom, sdkmath.NewInt(5000)), uatom, NewDecCoin(uatom, sdkmath.NewInt(5000000)), false}, // matom => uatom } for i, tc := range testCases { @@ -182,9 +184,9 @@ func (s *internalDenomTestSuite) TestDecOperationOrder() { dec, err = NewDecFromStr("100000011") s.Require().NoError(RegisterDenom("unit2", dec)) - coin, err := ConvertCoin(NewCoin("unit1", NewInt(100000011)), "unit2") + coin, err := ConvertCoin(NewCoin("unit1", sdkmath.NewInt(100000011)), "unit2") s.Require().NoError(err) - s.Require().Equal(coin, NewCoin("unit2", NewInt(11))) + s.Require().Equal(coin, NewCoin("unit2", sdkmath.NewInt(11))) // reset registration baseDenom = "" diff --git a/types/events_test.go b/types/events_test.go index 87622550d26a..16e4b328af64 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -9,6 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" testdata "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -74,7 +75,7 @@ func (s *eventsTestSuite) TestEventManager() { func (s *eventsTestSuite) TestEventManagerTypedEvents() { em := sdk.NewEventManager() - coin := sdk.NewCoin("fakedenom", sdk.NewInt(1999999)) + coin := sdk.NewCoin("fakedenom", sdkmath.NewInt(1999999)) cat := testdata.Cat{ Moniker: "Garfield", Lives: 6, diff --git a/types/math.go b/types/math.go index 9cb160e5fc2f..be20e1cfff72 100644 --- a/types/math.go +++ b/types/math.go @@ -1,7 +1,7 @@ package types import ( - mathmod "github.com/cosmos/cosmos-sdk/math" + sdkmath "github.com/cosmos/cosmos-sdk/math" ) // Type aliases to the SDK's math sub-module @@ -11,15 +11,15 @@ import ( // // Please use the above module instead of this package. type ( - Int = mathmod.Int - Uint = mathmod.Uint + Int = sdkmath.Int + Uint = sdkmath.Uint ) func (ip IntProto) String() string { return ip.Int.String() } -// ToDec converts Int to Dec +// ToDec converts an Int type to a Dec type. func ToDec(i Int) Dec { return NewDecFromInt(i) } diff --git a/types/proto.go b/types/proto.go new file mode 100644 index 000000000000..5f2df428d27d --- /dev/null +++ b/types/proto.go @@ -0,0 +1,15 @@ +package types + +// CustomProtobufType defines the interface custom gogo proto types must implement +// in order to be used as a "customtype" extension. +// +// ref: https://github.com/gogo/protobuf/blob/master/custom_types.md +type CustomProtobufType interface { + Marshal() ([]byte, error) + MarshalTo(data []byte) (n int, err error) + Unmarshal(data []byte) error + Size() int + + MarshalJSON() ([]byte, error) + UnmarshalJSON(data []byte) error +} diff --git a/types/simulation/rand_util.go b/types/simulation/rand_util.go index f136da396990..f359ad165182 100644 --- a/types/simulation/rand_util.go +++ b/types/simulation/rand_util.go @@ -7,6 +7,7 @@ import ( "time" "unsafe" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -41,13 +42,13 @@ func RandStringOfLength(r *rand.Rand, n int) string { // RandPositiveInt get a rand positive sdk.Int func RandPositiveInt(r *rand.Rand, max sdk.Int) (sdk.Int, error) { - if !max.GTE(sdk.OneInt()) { + if !max.GTE(sdkmath.OneInt()) { return sdk.Int{}, errors.New("max too small") } - max = max.Sub(sdk.OneInt()) + max = max.Sub(sdkmath.OneInt()) - return sdk.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdk.OneInt()), nil + return sdkmath.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdkmath.OneInt()), nil } // RandomAmount generates a random amount @@ -64,7 +65,7 @@ func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { randInt = big.NewInt(0).Rand(r, max.BigInt()) // up to max - 1 } - return sdk.NewIntFromBigInt(randInt) + return sdkmath.NewIntFromBigInt(randInt) } // RandomDecAmount generates a random decimal amount diff --git a/types/staking.go b/types/staking.go index 2f17bb1dd85f..f69ef8b5217c 100644 --- a/types/staking.go +++ b/types/staking.go @@ -1,5 +1,9 @@ package types +import ( + sdkmath "github.com/cosmos/cosmos-sdk/math" +) + // staking constants const ( @@ -19,7 +23,7 @@ const ( ) // DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power -var DefaultPowerReduction = NewIntFromUint64(1000000) +var DefaultPowerReduction = sdkmath.NewIntFromUint64(1000000) // TokensToConsensusPower - convert input tokens to potential consensus-engine power func TokensToConsensusPower(tokens Int, powerReduction Int) int64 { @@ -28,5 +32,5 @@ func TokensToConsensusPower(tokens Int, powerReduction Int) int64 { // TokensFromConsensusPower - convert input power to tokens func TokensFromConsensusPower(power int64, powerReduction Int) Int { - return NewInt(power).Mul(powerReduction) + return sdkmath.NewInt(power).Mul(powerReduction) } diff --git a/types/staking_test.go b/types/staking_test.go index fe6c36bd991b..22757263a573 100644 --- a/types/staking_test.go +++ b/types/staking_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/suite" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,6 +22,6 @@ func (s *stakingTestSuite) SetupSuite() { } func (s *stakingTestSuite) TestTokensToConsensusPower() { - s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999), sdk.DefaultPowerReduction)) - s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000), sdk.DefaultPowerReduction)) + s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdkmath.NewInt(999_999), sdk.DefaultPowerReduction)) + s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdkmath.NewInt(1_000_000), sdk.DefaultPowerReduction)) } From ba3e976023622732699ce99f2d4bc0c4e8a69864 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 14:47:38 -0400 Subject: [PATCH 08/22] updates --- go.mod | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 078f00546088..f2f3ac8f7433 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/cosmos/cosmos-sdk/api v0.1.0 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.5 + github.com/cosmos/cosmos-sdk/math v0.0.0-00010101000000-000000000000 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.18.0 github.com/cosmos/ledger-cosmos-go v0.11.1 @@ -59,8 +60,6 @@ require ( sigs.k8s.io/yaml v1.3.0 ) -require github.com/cosmos/cosmos-sdk/math v0.0.0-00010101000000-000000000000 - require ( cloud.google.com/go v0.100.2 // indirect cloud.google.com/go/compute v1.5.0 // indirect From 44bc9ec55a758f29ce5589b86dcf4a8e303dcabc Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:03:38 -0400 Subject: [PATCH 09/22] updates --- x/auth/client/testutil/suite.go | 61 ++++----- x/auth/middleware/branch_store_test.go | 3 +- x/auth/middleware/fee_test.go | 9 +- x/auth/middleware/feegrant_test.go | 5 +- x/auth/middleware/middleware_test.go | 12 +- x/auth/middleware/tips_test.go | 11 +- x/auth/migrations/legacytx/stdtx_test.go | 3 +- x/auth/migrations/v043/store_test.go | 121 +++++++++--------- x/auth/tx/builder_test.go | 3 +- x/auth/tx/service_test.go | 13 +- x/auth/vesting/client/testutil/suite.go | 18 +-- x/authz/client/testutil/grpc.go | 2 +- x/authz/client/testutil/query.go | 4 +- x/authz/client/testutil/tx.go | 104 +++++++-------- x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/keeper_test.go | 2 +- x/authz/module/abci_test.go | 7 +- x/authz/msgs_test.go | 7 +- x/authz/simulation/genesis.go | 2 +- x/bank/client/testutil/grpc.go | 10 +- x/bank/client/testutil/suite.go | 34 ++--- x/bank/keeper/genesis_test.go | 10 +- x/bank/keeper/keeper.go | 2 +- x/bank/keeper/keeper_test.go | 8 +- x/bank/migrations/v043/json_test.go | 14 +- x/bank/migrations/v043/store_test.go | 10 +- x/bank/migrations/v046/store_test.go | 4 +- x/bank/simulation/genesis.go | 4 +- x/bank/types/balance_test.go | 2 +- x/bank/types/send_authorization_test.go | 4 +- x/crisis/client/testsuite/suite.go | 6 +- x/crisis/types/genesis.go | 2 +- x/distribution/client/testutil/suite.go | 30 ++--- .../client/testutil/withdraw_all_suite.go | 19 +-- x/distribution/keeper/allocation_test.go | 22 ++-- x/distribution/keeper/delegation_test.go | 34 ++--- x/distribution/keeper/grpc_query_test.go | 4 +- x/distribution/keeper/keeper_test.go | 10 +- x/distribution/keeper/querier_test.go | 4 +- x/distribution/proposal_handler_test.go | 2 +- x/distribution/simulation/operations_test.go | 6 +- x/distribution/simulation/proposals_test.go | 2 +- x/feegrant/client/testutil/suite.go | 22 ++-- x/feegrant/keeper/genesis_test.go | 2 +- x/feegrant/keeper/keeper_test.go | 4 +- x/feegrant/migrations/v046/store_test.go | 5 +- x/feegrant/module/abci_test.go | 11 +- x/feegrant/msgs_test.go | 2 +- x/feegrant/simulation/decoder_test.go | 2 +- x/feegrant/simulation/genesis.go | 4 +- x/genutil/client/testutil/suite.go | 2 +- x/gov/client/cli/parse_test.go | 6 +- x/gov/client/testutil/deposits.go | 6 +- x/gov/client/testutil/helpers.go | 2 +- x/gov/client/testutil/query.go | 4 +- x/gov/client/testutil/tx.go | 50 ++++---- x/gov/genesis_test.go | 2 +- x/gov/keeper/common_test.go | 4 +- x/gov/keeper/deposit_test.go | 2 +- x/gov/keeper/grpc_query_test.go | 14 +- x/gov/keeper/keeper_test.go | 4 +- x/gov/keeper/msg_server_test.go | 16 +-- x/gov/keeper/querier_test.go | 2 +- x/gov/keeper/tally_test.go | 2 +- x/gov/keeper/vote_test.go | 2 +- x/gov/migrations/v046/convert_test.go | 13 +- x/gov/migrations/v046/json_test.go | 2 +- x/gov/types/v1/params.go | 2 +- x/gov/types/v1beta1/params.go | 2 +- x/group/client/testutil/query.go | 2 +- x/group/client/testutil/tx.go | 38 +++--- x/group/keeper/grpc_query_test.go | 7 +- x/group/keeper/keeper_test.go | 4 +- x/group/module/abci_test.go | 9 +- x/mint/types/minter.go | 2 +- x/mint/types/minter_test.go | 4 +- x/nft/client/testutil/tx.go | 6 +- x/nft/keeper/keeper_test.go | 2 +- x/params/keeper/keeper_test.go | 2 +- x/params/proposal_handler_test.go | 2 +- x/slashing/client/testutil/suite.go | 2 +- x/slashing/simulation/operations_test.go | 4 +- x/staking/bench_test.go | 2 +- x/staking/client/testutil/grpc.go | 6 +- x/staking/client/testutil/suite.go | 118 ++++++++--------- x/staking/client/testutil/test_helpers.go | 2 +- x/staking/genesis_test.go | 6 +- x/staking/keeper/common_test.go | 2 +- x/staking/keeper/delegation_test.go | 42 +++--- x/staking/keeper/historical_info_test.go | 6 +- x/staking/keeper/msg_server_test.go | 11 +- x/staking/keeper/power_reduction_test.go | 4 +- x/staking/keeper/querier_test.go | 6 +- x/staking/keeper/slash.go | 2 +- x/staking/keeper/slash_test.go | 32 ++--- x/staking/keeper/val_state_change.go | 2 +- x/staking/keeper/validator_test.go | 30 ++--- x/staking/simulation/genesis.go | 2 +- x/staking/simulation/operations_test.go | 5 +- x/staking/types/delegation_test.go | 18 +-- x/staking/types/msg_test.go | 2 +- x/staking/types/params.go | 2 +- x/staking/types/validator_test.go | 46 +++---- x/upgrade/keeper/keeper_test.go | 2 +- 104 files changed, 637 insertions(+), 616 deletions(-) diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 40aa258dd5e6..5b6b7fdb37ae 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -20,6 +20,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -86,8 +87,8 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestCLIValidateSignatures() { val := s.network.Validators[0] sendTokens := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))) + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))) res, err := s.createBankMsg(val, val.Address, sendTokens, fmt.Sprintf("--%s=true", flags.FlagGenerateOnly)) @@ -130,7 +131,7 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() { account, err := val.ClientCtx.AccountRetriever.GetAccount(val.ClientCtx, addr) s.Require().NoError(err) - sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))) + sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))) args := []string{ keyName, // from keyname val2.Address.String(), @@ -232,8 +233,8 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() { func (s *IntegrationTestSuite) TestCLISignBatch() { val := s.network.Validators[0] var sendTokens = sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ) generatedStd, err := s.createBankMsg(val, val.Address, @@ -285,8 +286,8 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() { val1 := s.network.Validators[0] txCfg := val1.ClientCtx.TxConfig var sendTokens = sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ) txBz, err := s.createBankMsg(val1, val1.Address, sendTokens, fmt.Sprintf("--%s=true", flags.FlagGenerateOnly)) @@ -604,7 +605,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { "fee event happy case", []string{ fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, @@ -613,7 +614,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { "no matching fee event", []string{ fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(0))).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, true, @@ -819,7 +820,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -930,7 +931,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -996,7 +997,7 @@ func (s *IntegrationTestSuite) TestSignWithMultisig() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1057,7 +1058,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1131,11 +1132,11 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() { addr, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1193,11 +1194,11 @@ func (s *IntegrationTestSuite) TestMultisignBatch() { addr, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1387,11 +1388,11 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { // Create a txBuilder with an unsigned tx. txBuilder := txCfg.NewTxBuilder() msg := banktypes.NewMsgSend(val1.Address, val1.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), )) err := txBuilder.SetMsgs(msg) s.Require().NoError(err) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)))) txBuilder.SetGasLimit(testdata.NewTestGasLimit()) // Set empty signature to set signer infos. sigV2 := signing.SignatureV2{ @@ -1442,8 +1443,8 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { require := s.Require() val0, val1 := s.network.Validators[0], s.network.Validators[1] - val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val0.Moniker), sdk.NewInt(10)) - val1Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdk.NewInt(10)) + val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val0.Moniker), sdkmath.NewInt(10)) + val1Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdkmath.NewInt(10)) _, _, addr1 := testdata.KeyTestPubAddr() // Creating a tx with 2 msgs from 2 signers: val0 and val1. @@ -1455,7 +1456,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { banktypes.NewMsgSend(val0.Address, addr1, sdk.NewCoins(val0Coin)), banktypes.NewMsgSend(val1.Address, addr1, sdk.NewCoins(val1Coin)), ) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)))) txBuilder.SetGasLimit(testdata.NewTestGasLimit() * 2) require.Equal([]sdk.AccAddress{val0.Address, val1.Address}, txBuilder.GetTx().GetSigners()) @@ -1508,7 +1509,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { func (s *IntegrationTestSuite) TestAuxSigner() { require := s.Require() val := s.network.Validators[0] - val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)) + val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)) testCases := []struct { name string @@ -1571,11 +1572,11 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipper, err := acc.GetAddress() require.NoError(err) - tipperInitialBal := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10000)) + tipperInitialBal := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10000)) feePayer := val.Address - fee := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000)) - tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(1000)) + fee := sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1000)) + tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(1000)) s.Require().NoError(s.network.WaitForNextBlock()) _, err = s.createBankMsg(val, tipper, sdk.NewCoins(tipperInitialBal)) @@ -1654,7 +1655,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "--tip flag unset: no error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), fmt.Sprintf("--%s=true", flags.FlagAux), @@ -1725,7 +1726,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "wrong denom in tip: error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, "1000wrongDenom"), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), @@ -1744,7 +1745,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "insufficient fees: error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, tip), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), @@ -1816,7 +1817,7 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk. flags := []string{fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } flags = append(flags, extraFlags...) diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go index 80e116fb2a82..d7f24464ebb4 100644 --- a/x/auth/middleware/branch_store_test.go +++ b/x/auth/middleware/branch_store_test.go @@ -6,6 +6,7 @@ import ( "math" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -37,7 +38,7 @@ func (s *MWTestSuite) TestBranchStore() { txBuilder := s.clientCtx.TxConfig.NewTxBuilder() // tx fee - feeCoin := sdk.NewCoin("atom", sdk.NewInt(150)) + feeCoin := sdk.NewCoin("atom", sdkmath.NewInt(150)) feeAmount := sdk.NewCoins(feeCoin) // test account and fund diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go index 9899e2aa63c3..30e35fcb58d7 100644 --- a/x/auth/middleware/fee_test.go +++ b/x/auth/middleware/fee_test.go @@ -2,6 +2,7 @@ package middleware_test import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" @@ -25,7 +26,7 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { // msg and signatures msg := testdata.NewTestMsg(addr1) - atomCoin := sdk.NewCoin("atom", sdk.NewInt(150)) + atomCoin := sdk.NewCoin("atom", sdkmath.NewInt(150)) apeCoin := sdk.NewInt64Coin("ape", 1500000) feeAmount := sdk.NewCoins(apeCoin, atomCoin) gasLimit := testdata.NewTestGasLimit() @@ -96,7 +97,7 @@ func (s *MWTestSuite) TestDeductFees() { // Set account with insufficient funds acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr1) s.app.AccountKeeper.SetAccount(ctx, acc) - coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10))) + coins := sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(10))) err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, coins) s.Require().NoError(err) @@ -110,14 +111,14 @@ func (s *MWTestSuite) TestDeductFees() { // Set account with sufficient funds s.app.AccountKeeper.SetAccount(ctx, acc) - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(200)))) s.Require().NoError(err) // DeliverTx _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) s.Require().Nil(err, "Tx did not error after account has been set with sufficient funds") - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(200)))) s.Require().NoError(err) // SimulateTx diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/middleware/feegrant_test.go index 547f57a589d1..cfe3d478ff34 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/middleware/feegrant_test.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,11 +49,11 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { priv5, _, addr5 := testdata.KeyTestPubAddr() // Set addr1 with insufficient funds - err := testutil.FundAccount(s.app.BankKeeper, ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) + err := testutil.FundAccount(s.app.BankKeeper, ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdkmath.NewInt(10))}) s.Require().NoError(err) // Set addr2 with more funds - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdkmath.NewInt(99999))}) s.Require().NoError(err) // grant fee allowance from `addr2` to `addr3` (plenty to pay) diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index d923b84b2c3d..b89d10c58d85 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -7,10 +7,14 @@ import ( "strings" "testing" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -20,8 +24,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" ) var testCoins = sdk.Coins{sdk.NewInt64Coin("atom", 10000000)} @@ -489,7 +491,7 @@ func (s *MWTestSuite) TestTxHandlerFees() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) s.Require().True(s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).Empty()) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(149))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(149))) err := testutil.FundAccount(s.app.BankKeeper, ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) s.Require().NoError(err) @@ -503,8 +505,8 @@ func (s *MWTestSuite) TestTxHandlerFees() { func() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdk.NewInt(150))) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(0))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdkmath.NewInt(150))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(0))) }, false, false, diff --git a/x/auth/middleware/tips_test.go b/x/auth/middleware/tips_test.go index 7fb50f7e0f0f..f3ec2fc6c7c6 100644 --- a/x/auth/middleware/tips_test.go +++ b/x/auth/middleware/tips_test.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" clienttx "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -18,8 +19,8 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) -var initialRegens = sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(1000))) -var initialAtoms = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(1000))) +var initialRegens = sdk.NewCoins(sdk.NewCoin("regen", sdkmath.NewInt(1000))) +var initialAtoms = sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(1000))) // setupAcctsForTips sets up 2 accounts: // - tipper has 1000 regens @@ -61,17 +62,17 @@ func (s *MWTestSuite) TestTips() { }{ { "wrong tip denom", - sdk.NewCoins(sdk.NewCoin("foobar", sdk.NewInt(1000))), initialAtoms, 200000, + sdk.NewCoins(sdk.NewCoin("foobar", sdkmath.NewInt(1000))), initialAtoms, 200000, true, "0foobar is smaller than 1000foobar: insufficient funds", }, { "insufficient tip from tipper", - sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(5000))), initialAtoms, 200000, + sdk.NewCoins(sdk.NewCoin("regen", sdkmath.NewInt(5000))), initialAtoms, 200000, true, "1000regen is smaller than 5000regen: insufficient funds", }, { "insufficient fees from feePayer", - initialRegens, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(5000))), 200000, + initialRegens, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(5000))), 200000, true, "1000atom is smaller than 5000atom: insufficient funds: insufficient funds", }, { diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index c883a2faa2ea..5ca52abcf715 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -164,7 +165,7 @@ func TestTxValidateBasic(t *testing.T) { // require to fail validation upon invalid fee badFee := NewTestStdFee() - badFee.Amount[0].Amount = sdk.NewInt(-5) + badFee.Amount[0].Amount = sdkmath.NewInt(-5) tx := NewTestTx(ctx, nil, nil, nil, nil, 0, badFee) err := tx.ValidateBasic() diff --git a/x/auth/migrations/v043/store_test.go b/x/auth/migrations/v043/store_test.go index cae87b96885c..7ca3925c41ee 100644 --- a/x/auth/migrations/v043/store_test.go +++ b/x/auth/migrations/v043/store_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -34,18 +35,18 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -59,14 +60,14 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -80,18 +81,18 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -105,12 +106,12 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -124,16 +125,16 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -146,16 +147,16 @@ func TestMigrateVestingAccounts(t *testing.T) { "not end time", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -168,12 +169,12 @@ func TestMigrateVestingAccounts(t *testing.T) { "delayed vesting has not vested, single delegation greater than the total account balance", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -187,14 +188,14 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -210,14 +211,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -233,14 +234,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -256,14 +257,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(-2, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -277,7 +278,7 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(100))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(100))) start := ctx.BlockTime().Unix() + int64(time.Hour/time.Second) @@ -292,7 +293,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, account) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(150), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(150), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -315,19 +316,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, } @@ -336,7 +337,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -359,19 +360,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, } @@ -382,7 +383,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -405,19 +406,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, } @@ -428,7 +429,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -451,19 +452,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), }, } @@ -474,7 +475,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -487,14 +488,14 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has unbonding delegations in place", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) @@ -503,7 +504,7 @@ func TestMigrateVestingAccounts(t *testing.T) { require.NoError(t, err) // un-delegation of the original vesting - _, err = app.StakingKeeper.Undelegate(ctx, delegatorAddr, valAddr, sdk.NewDecFromInt(sdk.NewInt(300))) + _, err = app.StakingKeeper.Undelegate(ctx, delegatorAddr, valAddr, sdk.NewDecFromInt(sdkmath.NewInt(300))) require.NoError(t, err) }, cleartTrackingFields, @@ -516,7 +517,7 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has never delegated anything", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) @@ -532,7 +533,7 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has no delegation but dirty DelegatedFree and DelegatedVesting fields", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) @@ -554,7 +555,7 @@ func TestMigrateVestingAccounts(t *testing.T) { Time: time.Now(), }) - addrs := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(tc.tokenAmount)) + addrs := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(tc.tokenAmount)) delegatorAddr := addrs[0] _, valAddr := createValidator(t, ctx, app, tc.tokenAmount*2) @@ -580,11 +581,11 @@ func TestMigrateVestingAccounts(t *testing.T) { var expFree sdk.Coins if tc.expVested != 0 { - expVested = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(tc.expVested))) + expVested = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(tc.expVested))) } if tc.expFree != 0 { - expFree = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(tc.expFree))) + expFree = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(tc.expFree))) } trackingCorrected( diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index f7122dd39218..c8d055bf5ba4 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -135,7 +136,7 @@ func TestBuilderValidateBasic(t *testing.T) { // require to fail validation upon invalid fee badFeeAmount := testdata.NewTestFeeAmount() - badFeeAmount[0].Amount = sdk.NewInt(-5) + badFeeAmount[0].Amount = sdkmath.NewInt(-5) txBuilder := newBuilder(nil) var sig1, sig2 signing.SignatureV2 diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index 28481c57c38c..d02fd0160d55 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/rest" @@ -69,11 +70,11 @@ func (s *IntegrationTestSuite) SetupSuite() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) @@ -86,12 +87,12 @@ func (s *IntegrationTestSuite) SetupSuite() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=2", flags.FlagSequence), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) @@ -551,7 +552,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() { sdk.NewCoins(coins), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), ) @@ -569,7 +570,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index 7f56de2c1cc2..378a6226d927 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -52,12 +52,12 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "create a continuous vesting account": { args: []string{ sdk.AccAddress("addr2_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -66,13 +66,13 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "create a delayed vesting account": { args: []string{ sdk.AccAddress("addr3_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", cli.FlagDelayed), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -81,7 +81,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "invalid address": { args: []string{ "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, @@ -103,7 +103,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "invalid end time": { args: []string{ sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), "-4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, @@ -159,11 +159,11 @@ func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { "create a permanent locked account": { args: []string{ sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -172,7 +172,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { "invalid address": { args: []string{ "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, diff --git a/x/authz/client/testutil/grpc.go b/x/authz/client/testutil/grpc.go index 6cf5e65ab76a..ee90de6ce3bf 100644 --- a/x/authz/client/testutil/grpc.go +++ b/x/authz/client/testutil/grpc.go @@ -115,7 +115,7 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { fmt.Sprintf("--%s=%s", cli.FlagMsgType, typeMsgVote), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 56296576507b..69ccc07ae708 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -30,7 +30,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -108,7 +108,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index da1cf903ed60..24bed9faa50c 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -73,7 +73,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) @@ -93,7 +93,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) @@ -127,9 +127,9 @@ func (s *IntegrationTestSuite) msgSendExec(grantee sdk.AccAddress) { val.ClientCtx, val.Address, grantee, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) s.Require().NoError(err) s.Require().Contains(out.String(), `"code":0`) @@ -205,7 +205,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), }, 0x1d, @@ -223,7 +223,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, true, @@ -239,7 +239,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -255,7 +255,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -271,7 +271,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -287,7 +287,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -302,7 +302,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -317,7 +317,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, false, @@ -332,7 +332,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, 0, true, @@ -347,7 +347,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, 0, @@ -397,7 +397,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -413,7 +413,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -429,7 +429,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, ) @@ -474,7 +474,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, &sdk.TxResponse{}, 0, false, @@ -487,7 +487,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, &sdk.TxResponse{}, 0, false, @@ -500,7 +500,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, &sdk.TxResponse{}, 0, @@ -542,7 +542,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, tenSeconds), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -560,7 +560,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }) s.Require().NoError(err) @@ -582,7 +582,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -627,7 +627,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, &sdk.TxResponse{}, @@ -640,7 +640,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -685,12 +685,12 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(12)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(12)), ) normalGeneratedTx, err := banktestutil.MsgSendExec( val.ClientCtx, @@ -699,7 +699,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { tokens, fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -717,7 +717,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -730,7 +730,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee1.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -743,7 +743,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -790,13 +790,13 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin("stake", sdk.NewInt(50)), + sdk.NewCoin("stake", sdkmath.NewInt(50)), ) delegateTx := fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -816,7 +816,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -829,7 +829,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -842,7 +842,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -881,12 +881,12 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens = sdk.NewCoins( - sdk.NewCoin("stake", sdk.NewInt(50)), + sdk.NewCoin("stake", sdkmath.NewInt(50)), ) delegateTx = fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -906,7 +906,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -919,7 +919,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -959,7 +959,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -968,7 +968,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), } cmd := cli.NewCmdExecAuthorization() @@ -994,7 +994,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -1008,13 +1008,13 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin("stake", sdk.NewInt(50)), + sdk.NewCoin("stake", sdkmath.NewInt(50)), ) undelegateTx := fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -1035,7 +1035,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1049,7 +1049,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1063,7 +1063,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -1102,12 +1102,12 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens = sdk.NewCoins( - sdk.NewCoin("stake", sdk.NewInt(50)), + sdk.NewCoin("stake", sdkmath.NewInt(50)), ) undelegateTx = fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -1128,7 +1128,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1142,7 +1142,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 077d2a162bd1..59bdf14cc195 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -37,7 +37,7 @@ var ( ) func (suite *GenesisTestSuite) TestImportExportGenesis() { - coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) + coins := sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(1_000))) now := suite.ctx.BlockTime() expires := now.Add(time.Hour) diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 223e3ad32617..170f6cf9c2ae 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -45,7 +45,7 @@ func (s *TestSuite) SetupTest() { s.app = app s.ctx = ctx s.queryClient = queryClient - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) } func (s *TestSuite) TestKeeper() { diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 5858476aeac5..04d234ec8676 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -4,20 +4,21 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestExpiredGrantsQueue(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, types.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) granter := addrs[0] grantee1 := addrs[1] grantee2 := addrs[2] diff --git a/x/authz/msgs_test.go b/x/authz/msgs_test.go index 7f85584121ed..fd62b5f5d2b4 100644 --- a/x/authz/msgs_test.go +++ b/x/authz/msgs_test.go @@ -1,10 +1,11 @@ package authz_test import ( - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" "time" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -151,11 +152,11 @@ func TestAminoJSON(t *testing.T) { require.NoError(t, err) grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt) require.NoError(t, err) - sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), &expiresAt) + sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000)))), &expiresAt) require.NoError(t, err) valAddr, err := sdk.ValAddressFromBech32("cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq") require.NoError(t, err) - stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000)}) + stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdkmath.NewInt(1000)}) require.NoError(t, err) delegateGrant, err := authz.NewGrant(blockTime, stakingAuth, nil) require.NoError(t, err) diff --git a/x/authz/simulation/genesis.go b/x/authz/simulation/genesis.go index 8c4609b7bb5c..cc976c34332a 100644 --- a/x/authz/simulation/genesis.go +++ b/x/authz/simulation/genesis.go @@ -37,7 +37,7 @@ func genGrant(r *rand.Rand, accounts []simtypes.Account, genT time.Time) []authz func generateRandomGrant(r *rand.Rand) *codectypes.Any { authorizations := make([]*codectypes.Any, 2) - authorizations[0] = newAnyAuthorization(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))))) + authorizations[0] = newAnyAuthorization(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))))) authorizations[1] = newAnyAuthorization(authz.NewGenericAuthorization(sdk.MsgTypeURL(&v1.MsgSubmitProposal{}))) return authorizations[r.Intn(len(authorizations))] diff --git a/x/bank/client/testutil/grpc.go b/x/bank/client/testutil/grpc.go index f09b26009011..3a91ff26ad99 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/testutil/grpc.go @@ -34,7 +34,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { &types.QueryTotalSupplyResponse{ Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), ), Pagination: &query.PageResponse{ Total: 2, @@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), }, }, { @@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(20))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(20))), }, }, { @@ -71,7 +71,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), }, }, { @@ -266,7 +266,7 @@ func (s *IntegrationTestSuite) TestBalancesGRPCHandler() { &types.QueryBalanceResponse{ Balance: &sdk.Coin{ Denom: "foobar", - Amount: sdk.NewInt(0), + Amount: sdkmath.NewInt(0), }, }, }, diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 539dfc5f3039..178297a7f1a1 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -183,7 +183,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { expected: &types.QueryTotalSupplyResponse{ Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), ), Pagination: &query.PageResponse{Total: 0}, }, @@ -198,7 +198,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { respType: &sdk.Coin{}, expected: &sdk.Coin{ Denom: s.cfg.BondDenom, - Amount: s.cfg.StakingTokens.Add(sdk.NewInt(10)), + Amount: s.cfg.StakingTokens.Add(sdkmath.NewInt(10)), }, }, { @@ -370,13 +370,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() { from := val.Address to := val.Address amount := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ) args := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), } @@ -404,13 +404,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -419,13 +419,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagOffline), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), }, @@ -436,13 +436,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1))).String()), }, false, sdkerrors.ErrInsufficientFee.ABCICode(), @@ -453,13 +453,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), "--gas=10", }, false, diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index d8fd84d2e290..01c5bf0916b4 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -74,11 +74,11 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { // Prepare some test data. defaultGenesis := types.DefaultGenesisState() balances := []types.Balance{ - {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(1))), Address: "cosmos1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0556gh0"}, - {Coins: sdk.NewCoins(sdk.NewCoin("barcoin", sdk.NewInt(1))), Address: "cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd"}, - {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(10)), sdk.NewCoin("barcoin", sdk.NewInt(20))), Address: "cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q"}, + {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(1))), Address: "cosmos1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0556gh0"}, + {Coins: sdk.NewCoins(sdk.NewCoin("barcoin", sdkmath.NewInt(1))), Address: "cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd"}, + {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(10)), sdk.NewCoin("barcoin", sdkmath.NewInt(20))), Address: "cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q"}, } - totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(11)), sdk.NewCoin("barcoin", sdk.NewInt(21))) + totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(11)), sdk.NewCoin("barcoin", sdkmath.NewInt(21))) genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) @@ -92,7 +92,7 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { }{ { "calculation NOT matching genesis Supply field", - types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdk.NewInt(1))), defaultGenesis.DenomMetadata), + types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdkmath.NewInt(1))), defaultGenesis.DenomMetadata), nil, true, "genesis supply is incorrect, expected 1wrongcoin, got 21barcoin,11foocoin", }, { diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 40492e33a358..36069ff2f82e 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -225,7 +225,7 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { if bz == nil { return sdk.Coin{ Denom: denom, - Amount: sdk.NewInt(0), + Amount: sdkmath.NewInt(0), } } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 7c3feb4c1c2f..3a2718542155 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -228,7 +228,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck - err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) + err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdkmath.NewInt(-10)}}) suite.Require().Error(err, "insufficient coins") suite.Require().Panics(func() { keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck @@ -905,7 +905,7 @@ func (suite *IntegrationTestSuite) TestDelegateCoins_Invalid() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) - invalidCoins := sdk.Coins{sdk.Coin{Denom: "fooDenom", Amount: sdk.NewInt(-50)}} + invalidCoins := sdk.Coins{sdk.Coin{Denom: "fooDenom", Amount: sdkmath.NewInt(-50)}} suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, invalidCoins)) app.AccountKeeper.SetAccount(ctx, macc) @@ -1063,7 +1063,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.app.BankKeeper.MintCoins( suite.ctx, multiPermAcc.Name, - sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(100000)))), + sdk.NewCoins(sdk.NewCoin("utxo", sdkmath.NewInt(100000)))), ) // send coins to address addr1 := sdk.AccAddress("addr1_______________") @@ -1072,7 +1072,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.ctx, multiPermAcc.Name, addr1, - sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(50000))), + sdk.NewCoins(sdk.NewCoin("utxo", sdkmath.NewInt(50000))), ), ) diff --git a/x/bank/migrations/v043/json_test.go b/x/bank/migrations/v043/json_test.go index 709b39c02920..8bb0c332708b 100644 --- a/x/bank/migrations/v043/json_test.go +++ b/x/bank/migrations/v043/json_test.go @@ -27,17 +27,17 @@ func TestMigrateJSON(t *testing.T) { { Address: voter.String(), Coins: sdk.Coins{ - sdk.NewCoin("foo", sdk.NewInt(10)), - sdk.NewCoin("bar", sdk.NewInt(20)), - sdk.NewCoin("foobar", sdk.NewInt(0)), + sdk.NewCoin("foo", sdkmath.NewInt(10)), + sdk.NewCoin("bar", sdkmath.NewInt(20)), + sdk.NewCoin("foobar", sdkmath.NewInt(0)), }, }, }, Supply: sdk.Coins{ - sdk.NewCoin("foo", sdk.NewInt(10)), - sdk.NewCoin("bar", sdk.NewInt(20)), - sdk.NewCoin("foobar", sdk.NewInt(0)), - sdk.NewCoin("barfoo", sdk.NewInt(0)), + sdk.NewCoin("foo", sdkmath.NewInt(10)), + sdk.NewCoin("bar", sdkmath.NewInt(20)), + sdk.NewCoin("foobar", sdkmath.NewInt(0)), + sdk.NewCoin("barfoo", sdkmath.NewInt(0)), }, } diff --git a/x/bank/migrations/v043/store_test.go b/x/bank/migrations/v043/store_test.go index 04117b3c3b32..4d18c3610de6 100644 --- a/x/bank/migrations/v043/store_test.go +++ b/x/bank/migrations/v043/store_test.go @@ -21,9 +21,9 @@ func TestSupplyMigration(t *testing.T) { ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) - oldFooCoin := sdk.NewCoin("foo", sdk.NewInt(100)) - oldBarCoin := sdk.NewCoin("bar", sdk.NewInt(200)) - oldFooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) // to ensure the zero denom coins pruned. + oldFooCoin := sdk.NewCoin("foo", sdkmath.NewInt(100)) + oldBarCoin := sdk.NewCoin("bar", sdkmath.NewInt(200)) + oldFooBarCoin := sdk.NewCoin("foobar", sdkmath.NewInt(0)) // to ensure the zero denom coins pruned. // Old supply was stored as a single blob under the `SupplyKey`. var oldSupply v042bank.SupplyI @@ -73,14 +73,14 @@ func TestBalanceKeysMigration(t *testing.T) { _, _, addr := testdata.KeyTestPubAddr() // set 10 foo coin - fooCoin := sdk.NewCoin("foo", sdk.NewInt(10)) + fooCoin := sdk.NewCoin("foo", sdkmath.NewInt(10)) oldFooKey := append(append(v042bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) fooBz, err := encCfg.Codec.Marshal(&fooCoin) require.NoError(t, err) store.Set(oldFooKey, fooBz) // set 0 foobar coin - fooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) + fooBarCoin := sdk.NewCoin("foobar", sdkmath.NewInt(0)) oldKeyFooBar := append(append(v042bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) fooBarBz, err := encCfg.Codec.Marshal(&fooBarCoin) require.NoError(t, err) diff --git a/x/bank/migrations/v046/store_test.go b/x/bank/migrations/v046/store_test.go index db44f2591fdc..4493cc405c2b 100644 --- a/x/bank/migrations/v046/store_test.go +++ b/x/bank/migrations/v046/store_test.go @@ -25,8 +25,8 @@ func TestMigrateStore(t *testing.T) { prefixAccStore := prefix.NewStore(store, v043.CreateAccountBalancesPrefix(addr)) balances := sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(10000)), - sdk.NewCoin("bar", sdk.NewInt(20000)), + sdk.NewCoin("foo", sdkmath.NewInt(10000)), + sdk.NewCoin("bar", sdkmath.NewInt(20000)), ) for _, b := range balances { diff --git a/x/bank/simulation/genesis.go b/x/bank/simulation/genesis.go index 9031d0336451..282e69b5ab01 100644 --- a/x/bank/simulation/genesis.go +++ b/x/bank/simulation/genesis.go @@ -43,7 +43,7 @@ func RandomGenesisBalances(simState *module.SimulationState) []types.Balance { for _, acc := range simState.Accounts { genesisBalances = append(genesisBalances, types.Balance{ Address: acc.Address.String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(simState.InitialStake))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(simState.InitialStake))), }) } @@ -65,7 +65,7 @@ func RandomizedGenState(simState *module.SimulationState) { ) numAccs := int64(len(simState.Accounts)) - totalSupply := sdk.NewInt(simState.InitialStake * (numAccs + simState.NumBonded)) + totalSupply := sdkmath.NewInt(simState.InitialStake * (numAccs + simState.NumBonded)) supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupply)) bankGenesis := types.GenesisState{ diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index 10ee2a74bf6e..c3f85498c6b8 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -59,7 +59,7 @@ func TestBalanceValidate(t *testing.T) { bank.Balance{ Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", Coins: sdk.Coins{ - sdk.Coin{Denom: "uatom", Amount: sdk.NewInt(-1)}, + sdk.Coin{Denom: "uatom", Amount: sdkmath.NewInt(-1)}, }, }, true, diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 5e058317f1e9..e281102c0c74 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -12,8 +12,8 @@ import ( ) var ( - coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) - coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(500))) + coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) + coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(500))) fromAddr = sdk.AccAddress("_____from _____") toAddr = sdk.AccAddress("_______to________") ) diff --git a/x/crisis/client/testsuite/suite.go b/x/crisis/client/testsuite/suite.go index c80679a2d4e6..36dc879e48b8 100644 --- a/x/crisis/client/testsuite/suite.go +++ b/x/crisis/client/testsuite/suite.go @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -68,7 +68,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -79,7 +79,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/crisis/types/genesis.go b/x/crisis/types/genesis.go index f53099130277..810e6e1e8573 100644 --- a/x/crisis/types/genesis.go +++ b/x/crisis/types/genesis.go @@ -16,7 +16,7 @@ func NewGenesisState(constantFee sdk.Coin) *GenesisState { // DefaultGenesisState creates a default GenesisState object func DefaultGenesisState() *GenesisState { return &GenesisState{ - ConstantFee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), + ConstantFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), } } diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index ac912952be25..1cffa69a0d3e 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -470,7 +470,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, []string{}, }, @@ -481,7 +481,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -495,7 +495,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=true", cli.FlagCommission), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -568,7 +568,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, []string{}, }, @@ -578,7 +578,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -653,7 +653,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -664,7 +664,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -708,18 +708,18 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, { "valid transaction", []string{ - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -757,11 +757,11 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { }` // fund some tokens to the community pool - args := []string{sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), + args := []string{sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String())} + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String())} invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp) cmd := cli.NewFundCommunityPoolCmd() @@ -778,7 +778,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { "recipient": "%s", "amount": "%s", "deposit": "%s" -}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) +}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { @@ -795,7 +795,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -806,7 +806,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/distribution/client/testutil/withdraw_all_suite.go b/x/distribution/client/testutil/withdraw_all_suite.go index 7b459a4dfde1..b0f96faf7d8a 100644 --- a/x/distribution/client/testutil/withdraw_all_suite.go +++ b/x/distribution/client/testutil/withdraw_all_suite.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -13,7 +15,6 @@ import ( banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" - "github.com/stretchr/testify/suite" ) type WithdrawAllTestSuite struct { @@ -62,20 +63,20 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) require.NoError(err) // delegate 500 tokens to validator1 args := []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(500)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(500)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } cmd := stakingcli.NewDelegateCmd() _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) @@ -84,11 +85,11 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { // delegate 500 tokens to validator2 args = []string{ val1.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(500)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(500)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) require.NoError(err) @@ -99,7 +100,7 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=1", cli.FlagMaxMessagesPerTx), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } cmd = cli.NewWithdrawAllRewardsCmd() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) @@ -113,7 +114,7 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=2", cli.FlagMaxMessagesPerTx), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } cmd = cli.NewWithdrawAllRewardsCmd() out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index d32b43690cac..7c9f97ddea53 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -20,13 +20,13 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 3, sdkmath.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdkmath.NewInt(100), true) val := app.StakingKeeper.Validator(ctx, valAddrs[0]) // allocate tokens @@ -52,17 +52,17 @@ func TestAllocateTokensToManyValidators(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, disttypes.InitialFeePool()) - addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) // create second validator with 0% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[1], valConsPk2, sdkmath.NewInt(100), true) abciValA := abci.Validator{ Address: valConsPk1.Address(), @@ -83,7 +83,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { require.True(t, app.DistrKeeper.GetValidatorCurrentRewards(ctx, valAddrs[1]).Rewards.IsZero()) // allocate tokens as if both had voted and second was proposer - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))) feeCollector := app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) require.NotNil(t, feeCollector) @@ -126,21 +126,21 @@ func TestAllocateTokensTruncation(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, disttypes.InitialFeePool()) - addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 3, sdkmath.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(110), true) // create second validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[1], valConsPk2, sdkmath.NewInt(100), true) // create third validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[2], valConsPk3, sdkmath.NewInt(100), true) abciValA := abci.Validator{ Address: valConsPk1.Address(), @@ -166,7 +166,7 @@ func TestAllocateTokensTruncation(t *testing.T) { require.True(t, app.DistrKeeper.GetValidatorCurrentRewards(ctx, valAddrs[1]).Rewards.IsZero()) // allocate tokens as if both had voted and second was proposer - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(634195840))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(634195840))) feeCollector := app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) require.NotNil(t, feeCollector) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index a1916913c424..511ebafe6fdc 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -22,12 +22,12 @@ func TestCalculateRewardsBasic(t *testing.T) { tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) // end block to bond validator and start new block staking.EndBlocker(ctx, app.StakingKeeper) @@ -75,7 +75,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -139,7 +139,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission @@ -214,12 +214,12 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) // end block to bond validator staking.EndBlocker(ctx, app.StakingKeeper) @@ -238,7 +238,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { // second delegation tstaking.Ctx = ctx - tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100)) + tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdkmath.NewInt(100)) del2 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0]) // fetch updated validator @@ -280,7 +280,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { balancePower := int64(1000) balanceTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, balancePower) - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -349,7 +349,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -418,7 +418,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission @@ -494,20 +494,20 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) initial := int64(20) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000))))) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))} // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) // end block to bond validator staking.EndBlocker(ctx, app.StakingKeeper) @@ -526,7 +526,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx)) // second delegation - tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100)) + tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdkmath.NewInt(100)) // historical count should be 3 (second delegation init) require.Equal(t, uint64(3), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx)) @@ -639,20 +639,20 @@ func Test100PercentCommissionReward(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) initial := int64(20) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000))))) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))} // create validator with 100% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(10, 1), sdk.NewDecWithPrec(10, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0]) // end block to bond validator diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index d51f4a28a0ba..3799badc2a66 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -41,7 +41,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.ctx = ctx suite.queryClient = queryClient - suite.addrs = simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + suite.addrs = simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) suite.valAddrs = simapp.ConvertAddrsToValAddrs(suite.addrs) } @@ -344,7 +344,7 @@ func (suite *KeeperTestSuite) TestGRPCDelegationRewards() { tstaking := teststaking.NewHelper(suite.T(), ctx, app.StakingKeeper) tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) staking.EndBlocker(ctx, app.StakingKeeper) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 9895e420bf80..0c91f107c8f0 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -17,7 +17,7 @@ func TestSetWithdrawAddr(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) params := app.DistrKeeper.GetParams(ctx) params.WithdrawAddrEnabled = false @@ -44,12 +44,12 @@ func TestWithdrawValidatorCommission(t *testing.T) { sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))), } - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdk.NewInt(2)), sdk.NewCoin("stake", sdk.NewInt(2))) + coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdkmath.NewInt(2)), sdk.NewCoin("stake", sdkmath.NewInt(2))) require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), coins)) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) @@ -73,7 +73,7 @@ func TestWithdrawValidatorCommission(t *testing.T) { // check balance increase balance = app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0])) require.Equal(t, sdk.NewCoins( - sdk.NewCoin("mytoken", sdk.NewInt(1)), + sdk.NewCoin("mytoken", sdkmath.NewInt(1)), sdk.NewCoin("stake", expTokens.AddRaw(1)), ), balance) @@ -96,7 +96,7 @@ func TestGetTotalRewards(t *testing.T) { sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))), } - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) app.DistrKeeper.SetValidatorOutstandingRewards(ctx, valAddrs[0], types.ValidatorOutstandingRewards{Rewards: valCommission}) diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index 9e1fe7cccce5..ea1060218fd8 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -122,7 +122,7 @@ func TestQueries(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, types.InitialFeePool()) - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) valOpAddr1 := valAddrs[0] @@ -175,7 +175,7 @@ func TestQueries(t *testing.T) { // test delegation rewards query tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valOpAddr1, valConsPk1, sdk.NewInt(100), true) + tstaking.CreateValidator(valOpAddr1, valConsPk1, sdkmath.NewInt(100), true) staking.EndBlocker(ctx, app.StakingKeeper) diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 24be6c98e5ae..7129310a29a7 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -18,7 +18,7 @@ var ( delPk1 = ed25519.GenPrivKey().PubKey() delAddr1 = sdk.AccAddress(delPk1.Address()) - amount = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))) + amount = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))) ) func testProposal(recipient sdk.AccAddress, amount sdk.Coins) *types.CommunityPoolSpendProposal { diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 4d70aab2eacf..5736844bc4f8 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -145,8 +145,8 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName // set module account coins distrAcc := suite.app.DistrKeeper.GetDistributionAccount(suite.ctx) suite.Require().NoError(testutil.FundModuleAccount(suite.app.BankKeeper, suite.ctx, distrAcc.GetName(), sdk.NewCoins( - sdk.NewCoin(tokenName, sdk.NewInt(10)), - sdk.NewCoin("stake", sdk.NewInt(5)), + sdk.NewCoin(tokenName, sdkmath.NewInt(10)), + sdk.NewCoin("stake", sdkmath.NewInt(5)), ))) suite.app.AccountKeeper.SetModuleAccount(suite.ctx, distrAcc) @@ -262,7 +262,7 @@ func (suite *SimTestSuite) getTestingValidator(accounts []simtypes.Account, comm validator, err = validator.SetInitialCommission(commission) require.NoError(err) validator.DelegatorShares = sdk.NewDec(100) - validator.Tokens = sdk.NewInt(1000000) + validator.Tokens = sdkmath.NewInt(1000000) suite.app.StakingKeeper.SetValidator(suite.ctx, validator) diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index aec70fd832c4..c3faf32802c4 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -34,7 +34,7 @@ func TestProposalContents(t *testing.T) { require.Equal(t, simulation.OpWeightSubmitCommunitySpendProposal, w0.AppParamsKey()) require.Equal(t, simappparams.DefaultWeightTextProposal, w0.DefaultWeight()) - amount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), sdk.NewCoin("atoken", sdk.NewInt(2))) + amount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)), sdk.NewCoin("atoken", sdkmath.NewInt(2))) feePool := app.DistrKeeper.GetFeePool(ctx) feePool.CommunityPool = sdk.NewDecCoinsFromCoins(amount...) diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index 5423a18e9503..335ee867eaad 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.createGrant(granter, grantee) grant, err := feegrant.NewGrant(granter, grantee, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))), }) s.Require().NoError(err) @@ -83,10 +83,10 @@ func (s *IntegrationTestSuite) createGrant(granter, grantee sdk.Address) { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), } - fee := sdk.NewCoin("stake", sdk.NewInt(100)) + fee := sdk.NewCoin("stake", sdkmath.NewInt(100)) args := append( []string{ @@ -323,7 +323,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } testCases := []struct { @@ -614,7 +614,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } // Create new fee grant specifically to test amino. @@ -727,10 +727,10 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } - fee := sdk.NewCoin("stake", sdk.NewInt(100)) + fee := sdk.NewCoin("stake", sdkmath.NewInt(100)) args := append( []string{ @@ -778,9 +778,9 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), } - spendLimit := sdk.NewCoin("stake", sdk.NewInt(1000)) + spendLimit := sdk.NewCoin("stake", sdkmath.NewInt(1000)) allowMsgs := strings.Join([]string{sdk.MsgTypeURL(&govv1beta1.MsgSubmitProposal{}), sdk.MsgTypeURL(&govv1.MsgVoteWeighted{})}, ",") @@ -895,7 +895,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { return govtestutil.MsgSubmitLegacyProposal(val.ClientCtx, grantee.String(), "Text Proposal", "No desc", govv1beta1.ProposalTypeText, fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), ) }, &sdk.TxResponse{}, @@ -906,7 +906,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { func() (testutil.BufferWriter, error) { return govtestutil.MsgVote(val.ClientCtx, grantee.String(), "0", "yes", fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), ) }, &sdk.TxResponse{}, diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go index 0c80780da57c..c729f71ff50f 100644 --- a/x/feegrant/keeper/genesis_test.go +++ b/x/feegrant/keeper/genesis_test.go @@ -36,7 +36,7 @@ var ( ) func (suite *GenesisTestSuite) TestImportExportGenesis() { - coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) + coins := sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(1_000))) now := suite.ctx.BlockHeader().Time oneYear := now.AddDate(1, 0, 0) msgSrvr := keeper.NewMsgServerImpl(suite.keeper) diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 933d85c7cefe..9adf84fa5461 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -35,11 +35,11 @@ func (suite *KeeperTestSuite) SetupTest() { suite.app = app suite.sdkCtx = ctx - suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) + suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 4, sdkmath.NewInt(30000000)) suite.ctx = sdk.WrapSDKContext(ctx) suite.keeper = suite.app.FeeGrantKeeper suite.msgSrvr = keeper.NewMsgServerImpl(suite.keeper) - suite.atom = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(555))) + suite.atom = sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(555))) } func (suite *KeeperTestSuite) TestKeeperCrud() { diff --git a/x/feegrant/migrations/v046/store_test.go b/x/feegrant/migrations/v046/store_test.go index 5d7cb5d9d073..b7fbcba049ff 100644 --- a/x/feegrant/migrations/v046/store_test.go +++ b/x/feegrant/migrations/v046/store_test.go @@ -4,13 +4,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant" v046 "github.com/cosmos/cosmos-sdk/x/feegrant/migrations/v046" - "github.com/stretchr/testify/require" ) func TestMigration(t *testing.T) { @@ -23,7 +24,7 @@ func TestMigration(t *testing.T) { granter2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) grantee2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) now := ctx.BlockTime() oneDay := now.AddDate(0, 0, 1) twoDays := now.AddDate(0, 0, 2) diff --git a/x/feegrant/module/abci_test.go b/x/feegrant/module/abci_test.go index 4c8aa03d410e..8edd31b61c0b 100644 --- a/x/feegrant/module/abci_test.go +++ b/x/feegrant/module/abci_test.go @@ -3,26 +3,27 @@ package module_test import ( "testing" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestFeegrantPruning(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 4, sdk.NewInt(1000)) + addrs := simapp.AddTestAddrs(app, ctx, 4, sdkmath.NewInt(1000)) granter1 := addrs[0] granter2 := addrs[1] granter3 := addrs[2] grantee := addrs[3] - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) now := ctx.BlockTime() oneDay := now.AddDate(0, 0, 1) diff --git a/x/feegrant/msgs_test.go b/x/feegrant/msgs_test.go index f33849557c97..b40b5e846524 100644 --- a/x/feegrant/msgs_test.go +++ b/x/feegrant/msgs_test.go @@ -137,7 +137,7 @@ func TestMsgRevokeAllowance(t *testing.T) { func TestAminoJSON(t *testing.T) { tx := legacytx.StdTx{} var msg legacytx.LegacyMsg - allowanceAny, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)))}) + allowanceAny, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(100)))}) require.NoError(t, err) // Amino JSON encoding has changed in feegrant since v0.46. diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index bb6fc789d76b..1cbf130489a4 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -26,7 +26,7 @@ func TestDecodeStore(t *testing.T) { dec := simulation.NewDecodeStore(cdc) grant, err := feegrant.NewGrant(granterAddr, granteeAddr, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(100))), }) require.NoError(t, err) diff --git a/x/feegrant/simulation/genesis.go b/x/feegrant/simulation/genesis.go index 7fbc8107c5bb..3464bf692a89 100644 --- a/x/feegrant/simulation/genesis.go +++ b/x/feegrant/simulation/genesis.go @@ -23,8 +23,8 @@ func genFeeGrants(r *rand.Rand, accounts []simtypes.Account) []feegrant.Grant { func generateRandomAllowances(granter, grantee sdk.AccAddress, r *rand.Rand) feegrant.Grant { allowances := make([]feegrant.Grant, 3) - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) - periodSpendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + periodSpendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(10))) basic := feegrant.BasicAllowance{ SpendLimit: spendLimit, diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index 755d20154eb3..f1e0f26fb457 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestGenTxCmd() { val := s.network.Validators[0] clientCtx := val.ClientCtx - amount := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(12)) + amount := sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(12)) tests := []struct { name string diff --git a/x/gov/client/cli/parse_test.go b/x/gov/client/cli/parse_test.go index e80c8c7c1a49..18f514882568 100644 --- a/x/gov/client/cli/parse_test.go +++ b/x/gov/client/cli/parse_test.go @@ -171,19 +171,19 @@ func TestParseSubmitProposal(t *testing.T) { // ok json msgs, metadata, deposit, err := parseSubmitProposal(cdc, okJSON.Name()) require.NoError(t, err, "unexpected error") - require.Equal(t, sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(1000))), deposit) + require.Equal(t, sdk.NewCoins(sdk.NewCoin("test", sdkmath.NewInt(1000))), deposit) require.Equal(t, base64.StdEncoding.EncodeToString(expectedMetadata), metadata) require.Len(t, msgs, 3) msg1, ok := msgs[0].(*banktypes.MsgSend) require.True(t, ok) require.Equal(t, addr.String(), msg1.FromAddress) require.Equal(t, addr.String(), msg1.ToAddress) - require.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))), msg1.Amount) + require.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(10))), msg1.Amount) msg2, ok := msgs[1].(*stakingtypes.MsgDelegate) require.True(t, ok) require.Equal(t, addr.String(), msg2.DelegatorAddress) require.Equal(t, addr.String(), msg2.ValidatorAddress) - require.Equal(t, sdk.NewCoin("stake", sdk.NewInt(10)), msg2.Amount) + require.Equal(t, sdk.NewCoin("stake", sdkmath.NewInt(10)), msg2.Amount) msg3, ok := msgs[2].(*v1.MsgExecLegacyContent) require.True(t, ok) require.Equal(t, addr.String(), msg3.Authority) diff --git a/x/gov/client/testutil/deposits.go b/x/gov/client/testutil/deposits.go index 8fc74ba1cdc8..d2919eb0649e 100644 --- a/x/gov/client/testutil/deposits.go +++ b/x/gov/client/testutil/deposits.go @@ -41,8 +41,8 @@ func (s *DepositTestSuite) SetupSuite() { val := s.network.Validators[0] deposits := sdk.Coins{ - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0)), - sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Sub(sdk.NewInt(50))), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(0)), + sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Sub(sdkmath.NewInt(50))), } s.deposits = deposits @@ -99,7 +99,7 @@ func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() { proposalID := s.proposalIDs[0] // deposit amount - depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Add(sdk.NewInt(50))).String() + depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Add(sdkmath.NewInt(50))).String() _, err := MsgDeposit(clientCtx, val.Address.String(), proposalID, depositAmount) s.Require().NoError(err) diff --git a/x/gov/client/testutil/helpers.go b/x/gov/client/testutil/helpers.go index 6dbb0d8722cb..8096be2f8b92 100644 --- a/x/gov/client/testutil/helpers.go +++ b/x/gov/client/testutil/helpers.go @@ -14,7 +14,7 @@ import ( var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), } // MsgSubmitLegacyProposal creates a tx for submit legacy proposal diff --git a/x/gov/client/testutil/query.go b/x/gov/client/testutil/query.go index 5f0502a8f039..1e4f0c05d96d 100644 --- a/x/gov/client/testutil/query.go +++ b/x/gov/client/testutil/query.go @@ -177,7 +177,7 @@ func (s *IntegrationTestSuite) TestCmdTally() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - v1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), + v1.NewTallyResult(sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0)), }, { "json output", @@ -186,7 +186,7 @@ func (s *IntegrationTestSuite) TestCmdTally() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - v1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), + v1.NewTallyResult(s.cfg.BondedTokens, sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0)), }, } diff --git a/x/gov/client/testutil/tx.go b/x/gov/client/testutil/tx.go index f3f5a52c4913..606f988c01cf 100644 --- a/x/gov/client/testutil/tx.go +++ b/x/gov/client/testutil/tx.go @@ -110,7 +110,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { ], "metadata": "%s", "deposit": "%s" -}`, authtypes.NewModuleAddress(types.ModuleName), base64.StdEncoding.EncodeToString(propMetadata), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) +}`, authtypes.NewModuleAddress(types.ModuleName), base64.StdEncoding.EncodeToString(propMetadata), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { @@ -125,7 +125,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { []string{ invalidPropFile.Name(), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -136,7 +136,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -176,7 +176,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { "description": "Hello, World!", "type": "Text", "deposit": "%s" -}`, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) +}`, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { name string @@ -191,7 +191,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s=%s", cli.FlagProposal, invalidPropFile.Name()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -200,10 +200,10 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { []string{ fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), - fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()), + fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -214,7 +214,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -224,11 +224,11 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), - fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()), + fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -266,11 +266,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { { "without proposal id", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, }, @@ -281,7 +281,7 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, }, @@ -289,11 +289,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { "deposit on non existing proposal", []string{ "10", - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 2, }, @@ -301,11 +301,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { "deposit on non existing proposal", []string{ "1", - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, @@ -355,7 +355,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 2, }, @@ -367,7 +367,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, @@ -380,7 +380,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, @@ -428,7 +428,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 2, }, @@ -440,7 +440,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, @@ -453,7 +453,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, @@ -465,7 +465,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, }, @@ -477,7 +477,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, }, diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 72057751177e..b12bf5bbfd4b 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -130,7 +130,7 @@ func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { Amount: sdk.Coins{ sdk.NewCoin( "stake", - sdk.NewInt(1234), + sdkmath.NewInt(1234), ), }, }, diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index e5e5bf183109..b258a5b5eb89 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -31,13 +31,13 @@ func getTestProposal() []sdk.Msg { } return []sdk.Msg{ - banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), + banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000)))), legacyProposalMsg, } } func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress) { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(5) cdc := simapp.MakeTestEncodingConfig().Codec diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 8d0a1986aae0..9f70bed9eba4 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -14,7 +14,7 @@ func TestDeposits(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000)) + TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 14b4286eeb4e..0f37e90f4923 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -588,7 +588,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryVote() { func (suite *KeeperTestSuite) TestGRPCQueryVotes() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) var ( req *v1.QueryVotesRequest @@ -689,7 +689,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() { func (suite *KeeperTestSuite) TestLegacyGRPCQueryVotes() { app, ctx, queryClient := suite.app, suite.ctx, suite.legacyQueryClient - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) var ( req *v1beta1.QueryVotesRequest @@ -1420,7 +1420,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() { expRes = &v1.QueryTallyResultResponse{ Tally: &v1.TallyResult{ - YesCount: sdk.NewInt(3 * 5 * 1000000).String(), + YesCount: sdkmath.NewInt(3 * 5 * 1000000).String(), NoCount: "0", AbstainCount: "0", NoWithVetoCount: "0", @@ -1531,10 +1531,10 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTally() { expRes = &v1beta1.QueryTallyResultResponse{ Tally: v1beta1.TallyResult{ - Yes: sdk.NewInt(3 * 5 * 1000000), - No: sdk.NewInt(0), - Abstain: sdk.NewInt(0), - NoWithVeto: sdk.NewInt(0), + Yes: sdkmath.NewInt(3 * 5 * 1000000), + No: sdkmath.NewInt(0), + Abstain: sdkmath.NewInt(0), + NoWithVeto: sdkmath.NewInt(0), }, } }, diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 95daf0797e62..188303689ca1 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) SetupTest() { // Populate the gov account with some coins, as the TestProposal we have // is a MsgSend from the gov account. - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100000))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100000))) err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) suite.NoError(err) err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, types.ModuleName, coins) @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) SetupTest() { govAcct := suite.app.GovKeeper.GetGovernanceAccount(suite.ctx).GetAddress() suite.legacyMsgSrvr = keeper.NewLegacyMsgServerImpl(govAcct.String(), suite.msgSrvr) - suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) + suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) } func TestIncrementProposalNumber(t *testing.T) { diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 5bdd9951089e..8634e3e14bdc 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -15,7 +15,7 @@ func (suite *KeeperTestSuite) TestSubmitProposalReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) initialDeposit := coins minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestVoteReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -347,7 +347,7 @@ func (suite *KeeperTestSuite) TestDepositReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -415,7 +415,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgSubmitProposal() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) initialDeposit := coins minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit @@ -465,7 +465,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgVote() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -567,7 +567,7 @@ func (suite *KeeperTestSuite) TestLegacyVoteWeighted() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -670,7 +670,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index 54a3e9fec49a..083ccf08c582 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -151,7 +151,7 @@ func TestQueries(t *testing.T) { legacyQuerierCdc := app.LegacyAmino() querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(20000001)) + TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(20000001)) oneCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)) consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index adb0d5a41609..106eb5b5b4d2 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -41,7 +41,7 @@ func TestTallyNoQuorum(t *testing.T) { createValidators(t, ctx, app, []int64{2, 5, 0}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/keeper/vote_test.go b/x/gov/keeper/vote_test.go index a1723c0f45b5..2c87f0f3f78d 100644 --- a/x/gov/keeper/vote_test.go +++ b/x/gov/keeper/vote_test.go @@ -15,7 +15,7 @@ func TestVotes(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/migrations/v046/convert_test.go b/x/gov/migrations/v046/convert_test.go index e8cbfedc2670..1d370a3ed2d2 100644 --- a/x/gov/migrations/v046/convert_test.go +++ b/x/gov/migrations/v046/convert_test.go @@ -4,12 +4,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" v046 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/stretchr/testify/require" ) func TestConvertToLegacyProposal(t *testing.T) { @@ -56,10 +57,10 @@ func TestConvertToLegacyProposal(t *testing.T) { require.Equal(t, v1beta1Proposal.VotingEndTime, *proposal.VotingEndTime) require.Equal(t, v1beta1Proposal.SubmitTime, *proposal.SubmitTime) require.Equal(t, v1beta1Proposal.DepositEndTime, *proposal.DepositEndTime) - require.Equal(t, v1beta1Proposal.FinalTallyResult.Yes, sdk.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.No, sdk.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.NoWithVeto, sdk.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.Abstain, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Yes, sdkmath.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.No, sdkmath.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.NoWithVeto, sdkmath.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Abstain, sdkmath.NewInt(0)) } }) } @@ -164,7 +165,7 @@ func TestConvertToLegacyDeposit(t *testing.T) { deposit := v1.Deposit{ ProposalId: 1, Depositor: "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh", - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))), } v1beta1Deposit := v046.ConvertToLegacyDeposit(&deposit) diff --git a/x/gov/migrations/v046/json_test.go b/x/gov/migrations/v046/json_test.go index 518161b9e8b5..4f9b72d457dc 100644 --- a/x/gov/migrations/v046/json_test.go +++ b/x/gov/migrations/v046/json_test.go @@ -43,7 +43,7 @@ func TestMigrateJSON(t *testing.T) { VotingEndTime: propTime, Status: v1beta1.StatusDepositPeriod, FinalTallyResult: v1beta1.EmptyTallyResult(), - TotalDeposit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(123))), + TotalDeposit: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(123))), }, } govGenState.Votes = v1beta1.Votes{ diff --git a/x/gov/types/v1/params.go b/x/gov/types/v1/params.go index b2321be75d55..88a03e5f5585 100644 --- a/x/gov/types/v1/params.go +++ b/x/gov/types/v1/params.go @@ -16,7 +16,7 @@ const ( // Default governance params var ( - DefaultMinDepositTokens = sdk.NewInt(10000000) + DefaultMinDepositTokens = sdkmath.NewInt(10000000) DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3) diff --git a/x/gov/types/v1beta1/params.go b/x/gov/types/v1beta1/params.go index 98f9b0390cbd..449d337a80bd 100644 --- a/x/gov/types/v1beta1/params.go +++ b/x/gov/types/v1beta1/params.go @@ -16,7 +16,7 @@ const ( // Default governance params var ( - DefaultMinDepositTokens = sdk.NewInt(10000000) + DefaultMinDepositTokens = sdkmath.NewInt(10000000) DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3) diff --git a/x/group/client/testutil/query.go b/x/group/client/testutil/query.go index 5ca1c06e6932..27e697148ca6 100644 --- a/x/group/client/testutil/query.go +++ b/x/group/client/testutil/query.go @@ -773,7 +773,7 @@ func (s *IntegrationTestSuite) TestTallyResult() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } // create a proposal diff --git a/x/group/client/testutil/tx.go b/x/group/client/testutil/tx.go index a32c6b4206be..5c3c0d945b3c 100644 --- a/x/group/client/testutil/tx.go +++ b/x/group/client/testutil/tx.go @@ -69,16 +69,16 @@ func (s *IntegrationTestSuite) SetupSuite() { val.ClientCtx, val.Address, account, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) s.Require().NoError(err) var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } memberWeight := "3" @@ -226,7 +226,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } validMembers := fmt.Sprintf(`{"members": [{ @@ -384,7 +384,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } groupIDs := make([]string, 2) @@ -510,7 +510,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } testCases := []struct { @@ -596,7 +596,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } validUpdatedMembersFileName := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ @@ -718,7 +718,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } validMembers := fmt.Sprintf(`{"members": [{ @@ -929,7 +929,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } groupID := s.group.Id @@ -1102,7 +1102,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyAdmin() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1206,7 +1206,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyDecisionPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1355,7 +1355,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyMetadata() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1472,7 +1472,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } testCases := []struct { @@ -1666,7 +1666,7 @@ func (s *IntegrationTestSuite) TestTxVote() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } ids := make([]string, 4) @@ -1859,7 +1859,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } ids := make([]string, 2) @@ -2007,7 +2007,7 @@ func (s *IntegrationTestSuite) TestTxExec() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } var proposalIDs []string @@ -2142,7 +2142,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { commonFlags := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } // create 3 accounts with some tokens @@ -2159,7 +2159,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { members[i-1] = account.String() _, err = banktestutil.MsgSendExec(clientCtx, val.Address, account, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))), commonFlags..., ) require.NoError(err) @@ -2330,7 +2330,7 @@ func (s *IntegrationTestSuite) createCLIProposal(groupPolicyAddress, proposer, s msg := banktypes.MsgSend{ FromAddress: sendFrom, ToAddress: sendTo, - Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))), + Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))), } msgJSON, err := s.cfg.Codec.MarshalInterfaceJSON(&msg) s.Require().NoError(err) diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index c9d91e728c26..10da51d36b87 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -4,12 +4,13 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/group" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestQueryGroupsByMember(t *testing.T) { @@ -20,7 +21,7 @@ func TestQueryGroupsByMember(t *testing.T) { queryClient := group.NewQueryClient(queryHelper) sdkCtx := sdk.WrapSDKContext(ctx) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 6, sdkmath.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index f5ef2c74fa68..6a9bdaad26ad 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -48,7 +48,7 @@ func (s *TestSuite) SetupTest() { s.sdkCtx = ctx s.ctx = sdk.WrapSDKContext(ctx) s.keeper = s.app.GroupKeeper - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 6, sdkmath.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ @@ -2655,7 +2655,7 @@ func (s *TestSuite) TestProposalsByVPEnd() { } func (s *TestSuite) TestLeaveGroup() { - addrs := simapp.AddTestAddrsIncremental(s.app, s.sdkCtx, 7, sdk.NewInt(3000000)) + addrs := simapp.AddTestAddrsIncremental(s.app, s.sdkCtx, 7, sdkmath.NewInt(3000000)) admin1 := addrs[0] member1 := addrs[1] member2 := addrs[2] diff --git a/x/group/module/abci_test.go b/x/group/module/abci_test.go index 5f510c864ed2..ac477d2234ab 100644 --- a/x/group/module/abci_test.go +++ b/x/group/module/abci_test.go @@ -5,14 +5,15 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/cosmos-sdk/x/group/module" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -20,7 +21,7 @@ import ( func TestEndBlockerPruning(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) addr1 := addrs[0] addr2 := addrs[1] addr3 := addrs[2] @@ -322,7 +323,7 @@ func TestEndBlockerTallying(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdkmath.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go index 3285d6ddf0e8..63253a9f4cf5 100644 --- a/x/mint/types/minter.go +++ b/x/mint/types/minter.go @@ -75,6 +75,6 @@ func (m Minter) NextAnnualProvisions(_ Params, totalSupply sdk.Int) sdk.Dec { // BlockProvision returns the provisions for a block based on the annual // provisions rate. func (m Minter) BlockProvision(params Params) sdk.Coin { - provisionAmt := m.AnnualProvisions.QuoInt(sdk.NewInt(int64(params.BlocksPerYear))) + provisionAmt := m.AnnualProvisions.QuoInt(sdkmath.NewInt(int64(params.BlocksPerYear))) return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt()) } diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 4abedb51cd05..c0f03aa1bc94 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -74,7 +74,7 @@ func TestBlockProvision(t *testing.T) { provisions := minter.BlockProvision(params) expProvisions := sdk.NewCoin(params.MintDenom, - sdk.NewInt(tc.expProvisions)) + sdkmath.NewInt(tc.expProvisions)) require.True(t, expProvisions.IsEqual(provisions), "test: %v\n\tExp: %v\n\tGot: %v\n", @@ -124,7 +124,7 @@ func BenchmarkNextAnnualProvisions(b *testing.B) { b.ReportAllocs() minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) params := DefaultParams() - totalSupply := sdk.NewInt(100000000000000) + totalSupply := sdkmath.NewInt(100000000000000) // run the NextAnnualProvisions function b.N times for n := 0; n < b.N; n++ { diff --git a/x/nft/client/testutil/tx.go b/x/nft/client/testutil/tx.go index e95bbf6b13d1..409493c0998f 100644 --- a/x/nft/client/testutil/tx.go +++ b/x/nft/client/testutil/tx.go @@ -101,7 +101,7 @@ func (s *IntegrationTestSuite) TestCLITxSend() { fmt.Sprintf("--%s=%s", flags.FlagFrom, OwnerName), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } testCases := []struct { name string @@ -154,13 +154,13 @@ func (s *IntegrationTestSuite) initAccount() { args := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), } s.owner, err = keyinfo.GetAddress() s.Require().NoError(err) - amount := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))) + amount := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))) _, err = banktestutil.MsgSendExec(ctx, val.Address, s.owner, amount, args...) s.Require().NoError(err) } diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go index 7e03f79eb582..448c69c74baf 100644 --- a/x/nft/keeper/keeper_test.go +++ b/x/nft/keeper/keeper_test.go @@ -45,7 +45,7 @@ func (s *TestSuite) SetupTest() { s.app = app s.ctx = ctx s.queryClient = queryClient - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) } func TestTestSuite(t *testing.T) { diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 92e2afb9185e..3f8c187e4885 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -181,7 +181,7 @@ func TestSubspace(t *testing.T) { {"uint16", uint16(1), uint16(0), new(uint16)}, {"uint32", uint32(1), uint32(0), new(uint32)}, {"uint64", uint64(1), uint64(0), new(uint64)}, - {"int", sdk.NewInt(1), *new(sdk.Int), new(sdk.Int)}, + {"int", sdkmath.NewInt(1), *new(sdk.Int), new(sdk.Int)}, {"uint", sdk.NewUint(1), *new(sdk.Uint), new(sdk.Uint)}, {"dec", sdk.NewDec(1), *new(sdk.Dec), new(sdk.Dec)}, {"struct", s{1}, s{0}, new(s)}, diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index 7b4bb36d6307..cd4f0938fa0a 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -72,7 +72,7 @@ func (suite *HandlerTestSuite) TestProposalHandler() { depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx) defaultPeriod := govv1.DefaultPeriod suite.Require().Equal(govv1.DepositParams{ - MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))), + MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(64000000))), MaxDepositPeriod: &defaultPeriod, }, depositParams) }, diff --git a/x/slashing/client/testutil/suite.go b/x/slashing/client/testutil/suite.go index 06bcdca70110..9fbd6ce3f5bf 100644 --- a/x/slashing/client/testutil/suite.go +++ b/x/slashing/client/testutil/suite.go @@ -157,7 +157,7 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index a0dbffb1f360..a191bfb79706 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -123,7 +123,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -163,7 +163,7 @@ func getTestingValidator(t *testing.T, app *simapp.SimApp, ctx sdk.Context, acco require.NoError(t, err) validator.DelegatorShares = sdk.NewDec(100) - validator.Tokens = sdk.NewInt(1000000) + validator.Tokens = sdkmath.NewInt(1000000) app.StakingKeeper.SetValidator(ctx, validator) diff --git a/x/staking/bench_test.go b/x/staking/bench_test.go index 7705b6d3114f..0a6faac5a0f5 100644 --- a/x/staking/bench_test.go +++ b/x/staking/bench_test.go @@ -31,7 +31,7 @@ func benchmarkValidateGenesis(b *testing.B, n int) { addr, pubKey := addressL[i], pubKeyL[i] validator := teststaking.NewValidator(b, addr, pubKey) ni := int64(i + 1) - validator.Tokens = sdk.NewInt(ni) + validator.Tokens = sdkmath.NewInt(ni) validator.DelegatorShares = sdk.NewDec(ni) validators = append(validators, validator) } diff --git a/x/staking/client/testutil/grpc.go b/x/staking/client/testutil/grpc.go index 26093aa15bc3..3b0971d61542 100644 --- a/x/staking/client/testutil/grpc.go +++ b/x/staking/client/testutil/grpc.go @@ -272,7 +272,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegation() { ValidatorAddress: val2.ValAddress.String(), Shares: sdk.NewDec(10), }, - Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)), + Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10)), }, }, }, @@ -751,8 +751,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryPool() { &types.QueryPoolResponse{}, &types.QueryPoolResponse{ Pool: types.Pool{ - NotBondedTokens: sdk.NewInt(0), - BondedTokens: cli.DefaultTokens.Mul(sdk.NewInt(2)), + NotBondedTokens: sdkmath.NewInt(0), + BondedTokens: cli.DefaultTokens.Mul(sdkmath.NewInt(2)), }, }, }, diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index 879808868eb9..ef1965905bf1 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -74,7 +74,7 @@ func (s *IntegrationTestSuite) SetupSuite() { _, err = s.network.WaitForHeight(1) s.Require().NoError(err) - unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5)) + unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5)) // unbonding the amount out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount) s.Require().NoError(err) @@ -116,9 +116,9 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) require.NoError(err) @@ -143,7 +143,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -162,7 +162,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -182,7 +182,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -203,7 +203,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -366,7 +366,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() { ValidatorAddress: val2.ValAddress.String(), Shares: sdk.NewDec(10), }, - Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)), + Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10)), }, }, } @@ -932,7 +932,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryPool() { fmt.Sprintf("--%s=1", flags.FlagHeight), }, fmt.Sprintf(`bonded_tokens: "%s" -not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), +not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdkmath.NewInt(2)).String()), }, { "with json", @@ -940,7 +940,7 @@ not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), fmt.Sprintf("--%s=1", flags.FlagHeight), }, - fmt.Sprintf(`{"not_bonded_tokens":"0","bonded_tokens":"%s"}`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), + fmt.Sprintf(`{"not_bonded_tokens":"0","bonded_tokens":"%s"}`, cli.DefaultTokens.Mul(sdkmath.NewInt(2)).String()), }, } for _, tc := range testCases { @@ -976,7 +976,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, "with wrong from address"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -986,7 +986,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -997,7 +997,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1008,7 +1008,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1019,7 +1019,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1030,7 +1030,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1044,7 +1044,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1086,9 +1086,9 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) s.Require().NoError(err) @@ -1106,18 +1106,18 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, { "without validator address", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -1125,11 +1125,11 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { "valid transaction of delegate", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1175,47 +1175,47 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, { "with wrong source validator address", []string{ - `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr - val2.ValAddress.String(), // dst-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount + `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr + val2.ValAddress.String(), // dst-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 3, &sdk.TxResponse{}, }, { "with wrong destination validator address", []string{ - val.ValAddress.String(), // dst-validator-addr - `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount + val.ValAddress.String(), // dst-validator-addr + `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 31, &sdk.TxResponse{}, }, { "valid transaction of delegate", []string{ - val.ValAddress.String(), // src-validator-addr - val2.ValAddress.String(), // dst-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount + val.ValAddress.String(), // src-validator-addr + val2.ValAddress.String(), // dst-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1259,18 +1259,18 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, { "Without validator address", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -1278,11 +1278,11 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() { "valid transaction of unbond", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1325,7 +1325,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -1336,7 +1336,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -1344,11 +1344,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Without unbond creation height", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, true, 0, nil, }, @@ -1356,12 +1356,12 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Wrong unbonding creation height", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), - sdk.NewInt(10000).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), + sdkmath.NewInt(10000).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, sdkerrors.ErrNotFound.ABCICode(), &sdk.TxResponse{}, }, @@ -1369,11 +1369,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Invalid unbonding amount (higher than the unbonding amount)", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10000)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10000)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, sdkerrors.ErrInvalidRequest.ABCICode(), &sdk.TxResponse{}, }, @@ -1381,11 +1381,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "valid transaction of canceling unbonding delegation", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1447,9 +1447,9 @@ func (s *IntegrationTestSuite) TestBlockResults() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), ) require.NoError(err) @@ -1459,11 +1459,11 @@ func (s *IntegrationTestSuite) TestBlockResults() { cmd := cli.NewDelegateCmd() _, err = clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }) require.NoError(err) @@ -1514,7 +1514,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", cli.FlagEditMoniker, moniker), fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }) require.NoError(err) @@ -1534,7 +1534,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), }) require.NoError(err) diff --git a/x/staking/client/testutil/test_helpers.go b/x/staking/client/testutil/test_helpers.go index 3a31ea004f3d..7adc43d8e711 100644 --- a/x/staking/client/testutil/test_helpers.go +++ b/x/staking/client/testutil/test_helpers.go @@ -14,7 +14,7 @@ import ( var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), } // MsgRedelegateExec creates a redelegate message. diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index df6120b04361..e8a933bc77d2 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -23,7 +23,7 @@ import ( func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { _, app, ctx := getBaseSimappWithCustomKeeper(t) - addrDels, _ := generateAddresses(app, ctx, numAddrs, sdk.NewInt(10000)) + addrDels, _ := generateAddresses(app, ctx, numAddrs, sdkmath.NewInt(10000)) return app, ctx, addrDels } @@ -125,8 +125,8 @@ func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { OperatorAddress: sdk.ValAddress("12345678901234567890").String(), ConsensusPubkey: consPub, Jailed: false, - Tokens: sdk.NewInt(10), - DelegatorShares: sdk.NewInt(10).ToDec(), + Tokens: sdkmath.NewInt(10), + DelegatorShares: sdkmath.NewInt(10).ToDec(), Description: types.NewDescription("bloop", "", "", "", ""), } // valid params diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index 6833ea4c0baf..0b2fe5529015 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -44,7 +44,7 @@ func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, ty // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int) ([]sdk.AccAddress, []sdk.ValAddress) { - addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdk.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdkmath.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) return addrDels, addrVals diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index 345121e4ed60..ada6a4ce2487 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -28,11 +28,11 @@ func TestDelegation(t *testing.T) { DelegatorAddress: delegations[0].DelegatorAddress, }) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrDels) //construct the validators - amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)} + amts := []sdk.Int{sdkmath.NewInt(9), sdkmath.NewInt(8), sdkmath.NewInt(7)} var validators [3]types.Validator for i, amt := range amts { validators[i] = teststaking.NewValidator(t, valAddrs[i], PKs[i]) @@ -149,7 +149,7 @@ func TestDelegation(t *testing.T) { func TestUnbondingDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) ubd := types.NewUnbondingDelegation( @@ -157,7 +157,7 @@ func TestUnbondingDelegation(t *testing.T) { valAddrs[0], 0, time.Unix(0, 0).UTC(), - sdk.NewInt(5), + sdkmath.NewInt(5), ) // set and retrieve a record @@ -167,7 +167,7 @@ func TestUnbondingDelegation(t *testing.T) { require.Equal(t, ubd, resUnbond) // modify a records, save, and retrieve - expUnbond := sdk.NewInt(21) + expUnbond := sdkmath.NewInt(21) ubd.Entries[0].Balance = expUnbond app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) @@ -199,7 +199,7 @@ func TestUnbondingDelegation(t *testing.T) { func TestUnbondDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -238,7 +238,7 @@ func TestUnbondDelegation(t *testing.T) { func TestUnbondingDelegationsMaxEntries(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -320,7 +320,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) @@ -382,7 +382,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) //create a validator with a self-delegation @@ -458,7 +458,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { ubd, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[1], addrVals[0]) require.True(t, found) require.Len(t, ubd.Entries, 1) - require.True(t, ubd.Entries[0].Balance.Equal(sdk.NewInt(6))) + require.True(t, ubd.Entries[0].Balance.Equal(sdkmath.NewInt(6))) assert.Equal(t, blockHeight2, ubd.Entries[0].CreationHeight) assert.True(t, blockTime2.Add(params.UnbondingTime).Equal(ubd.Entries[0].CompletionTime)) } @@ -468,7 +468,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // add bonded tokens to pool for delegations @@ -549,7 +549,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // add bonded tokens to pool for delegations @@ -620,11 +620,11 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { func TestGetRedelegationsFromSrcValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(0, 0), sdk.NewInt(5), + time.Unix(0, 0), sdkmath.NewInt(5), sdk.NewDec(5)) // set and retrieve a record @@ -647,11 +647,11 @@ func TestGetRedelegationsFromSrcValidator(t *testing.T) { func TestRedelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(0, 0).UTC(), sdk.NewInt(5), + time.Unix(0, 0).UTC(), sdkmath.NewInt(5), sdk.NewDec(5)) // test shouldn't have and redelegations @@ -710,7 +710,7 @@ func TestRedelegation(t *testing.T) { func TestRedelegateToSameValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -739,7 +739,7 @@ func TestRedelegateToSameValidator(t *testing.T) { func TestRedelegationMaxEntries(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) @@ -795,7 +795,7 @@ func TestRedelegationMaxEntries(t *testing.T) { func TestRedelegateSelfDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) @@ -851,7 +851,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { func TestRedelegateFromUnbondingValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) @@ -933,7 +933,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { func TestRedelegateFromUnbondedValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index 437269956936..f4c98e57b3af 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -26,7 +26,7 @@ func IsValSetSorted(data []types.Validator, powerReduction sdk.Int) bool { func TestHistoricalInfo(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) validators := make([]types.Validator, len(addrVals)) @@ -53,7 +53,7 @@ func TestHistoricalInfo(t *testing.T) { func TestTrackHistoricalInfo(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // set historical entries in params to 5 @@ -139,7 +139,7 @@ func TestGetAllHistoricalInfo(t *testing.T) { require.Len(t, infos, 1) app.StakingKeeper.DeleteHistoricalInfo(ctx, infos[0].Header.Height) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) valSet := []types.Validator{ diff --git a/x/staking/keeper/msg_server_test.go b/x/staking/keeper/msg_server_test.go index 44538be4d4ae..46b28c414e17 100644 --- a/x/staking/keeper/msg_server_test.go +++ b/x/staking/keeper/msg_server_test.go @@ -4,13 +4,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestCancelUnbondingDelegation(t *testing.T) { @@ -31,7 +32,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { require.Equal(t, sdk.NewInt64Coin(bondDenom, startTokens.Int64()), moduleBalance) // accounts - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000)) validators := app.StakingKeeper.GetValidators(ctx, 10) require.Equal(t, len(validators), 1) @@ -64,7 +65,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { req: types.MsgCancelUnbondingDelegation{ DelegatorAddress: resUnbond.DelegatorAddress, ValidatorAddress: resUnbond.ValidatorAddress, - Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(4)), + Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(4)), CreationHeight: 0, }, }, @@ -74,7 +75,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { req: types.MsgCancelUnbondingDelegation{ DelegatorAddress: resUnbond.DelegatorAddress, ValidatorAddress: resUnbond.ValidatorAddress, - Amount: sdk.NewCoin("dump_coin", sdk.NewInt(4)), + Amount: sdk.NewCoin("dump_coin", sdkmath.NewInt(4)), CreationHeight: 0, }, }, diff --git a/x/staking/keeper/power_reduction_test.go b/x/staking/keeper/power_reduction_test.go index e18230d854b2..9918124c42b6 100644 --- a/x/staking/keeper/power_reduction_test.go +++ b/x/staking/keeper/power_reduction_test.go @@ -5,11 +5,11 @@ import ( ) func (suite *KeeperTestSuite) TestTokensToConsensusPower() { - suite.Require().Equal(int64(0), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction.Sub(sdk.NewInt(1)))) + suite.Require().Equal(int64(0), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction.Sub(sdkmath.NewInt(1)))) suite.Require().Equal(int64(1), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction)) } func (suite *KeeperTestSuite) TestTokensFromConsensusPower() { - suite.Require().Equal(sdk.NewInt(0), suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 0)) + suite.Require().Equal(sdkmath.NewInt(0), suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 0)) suite.Require().Equal(sdk.DefaultPowerReduction, suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 1)) } diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index f50e95a1833e..b7343ff4b06d 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -19,12 +19,12 @@ import ( func TestNewQuerier(t *testing.T) { cdc, app, ctx := createTestInput(t) - addrs := simapp.AddTestAddrs(app, ctx, 500, sdk.NewInt(10000)) + addrs := simapp.AddTestAddrs(app, ctx, 500, sdkmath.NewInt(10000)) _, addrAcc2 := addrs[0], addrs[1] addrVal1, _ := sdk.ValAddress(addrs[0]), sdk.ValAddress(addrs[1]) // Create Validators - amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8)} + amts := []sdk.Int{sdkmath.NewInt(9), sdkmath.NewInt(8)} var validators [2]types.Validator for i, amt := range amts { validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i]) @@ -143,7 +143,7 @@ func TestQueryValidators(t *testing.T) { addrs := simapp.AddTestAddrs(app, ctx, 500, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) // Create Validators - amts := []sdk.Int{sdk.NewInt(8), sdk.NewInt(7)} + amts := []sdk.Int{sdkmath.NewInt(8), sdkmath.NewInt(7)} status := []types.BondStatus{types.Unbonded, types.Unbonding} var validators [2]types.Validator for i, amt := range amts { diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 279af3a85a35..a15cdfbfc711 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -45,7 +45,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh "WARNING: ignored attempt to slash a nonexistent validator; we recommend you investigate immediately", "validator", consAddr.String(), ) - return sdk.NewInt(0) + return sdkmath.NewInt(0) } // should not be slashing an unbonded validator diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 014173d9d075..704197317c96 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -81,19 +81,19 @@ func TestSlashUnbondingDelegation(t *testing.T) { // set an unbonding delegation with expiration timestamp (beyond which the // unbonding delegation shouldn't be slashed) ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 0, - time.Unix(5, 0), sdk.NewInt(10)) + time.Unix(5, 0), sdkmath.NewInt(10)) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) // unbonding started prior to the infraction height, stakw didn't contribute slashAmount := app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 1, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(0))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) // after the expiration time, no longer eligible for slashing ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(0))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) // test valid slash, before expiration timestamp and to which stake contributed notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx) @@ -101,19 +101,19 @@ func TestSlashUnbondingDelegation(t *testing.T) { ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(0, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(5))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(5))) ubd, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0]) require.True(t, found) require.Len(t, ubd.Entries, 1) // initial balance unchanged - require.Equal(t, sdk.NewInt(10), ubd.Entries[0].InitialBalance) + require.Equal(t, sdkmath.NewInt(10), ubd.Entries[0].InitialBalance) // balance decreased - require.Equal(t, sdk.NewInt(5), ubd.Entries[0].Balance) + require.Equal(t, sdkmath.NewInt(5), ubd.Entries[0].Balance) newUnbondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) diffTokens := oldUnbondedPoolBalances.Sub(newUnbondedPoolBalances...) - require.True(t, diffTokens.AmountOf(app.StakingKeeper.BondDenom(ctx)).Equal(sdk.NewInt(5))) + require.True(t, diffTokens.AmountOf(app.StakingKeeper.BondDenom(ctx)).Equal(sdkmath.NewInt(5))) } // tests slashRedelegation @@ -132,7 +132,7 @@ func TestSlashRedelegation(t *testing.T) { // set a redelegation with an expiration timestamp beyond which the // redelegation shouldn't be slashed rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(5, 0), sdk.NewInt(10), sdk.NewDec(10)) + time.Unix(5, 0), sdkmath.NewInt(10), sdk.NewDec(10)) app.StakingKeeper.SetRedelegation(ctx, rd) @@ -144,7 +144,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found := app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount := app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 1, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(0))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) // after the expiration time, no longer eligible for slashing ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) @@ -152,7 +152,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount = app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 0, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(0))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) balances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -162,7 +162,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount = app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 0, fraction) - require.True(t, slashAmount.Equal(sdk.NewInt(5))) + require.True(t, slashAmount.Equal(sdkmath.NewInt(5))) rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) require.True(t, found) require.Len(t, rd.Entries, 1) @@ -171,7 +171,7 @@ func TestSlashRedelegation(t *testing.T) { applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1) // initialbalance unchanged - require.Equal(t, sdk.NewInt(10), rd.Entries[0].InitialBalance) + require.Equal(t, sdkmath.NewInt(10), rd.Entries[0].InitialBalance) // shares decreased del, found = app.StakingKeeper.GetDelegation(ctx, addrDels[0], addrVals[1]) @@ -312,7 +312,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance decreased again - require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -338,7 +338,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance unchanged - require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -364,7 +364,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance unchanged - require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) // just 1 bonded token burned again since that's all the validator now has newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -616,5 +616,5 @@ func TestSlashAmount(t *testing.T) { // test the case where the validator was not found, which should return no coins _, addrVals := generateAddresses(app, ctx, 100) noBurned := app.StakingKeeper.Slash(ctx, sdk.ConsAddress(addrVals[0]), ctx.BlockHeight(), 10, fraction) - require.True(t, sdk.NewInt(0).Equal(noBurned)) + require.True(t, sdkmath.NewInt(0).Equal(noBurned)) } diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 7392936f5421..afddade3f540 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -183,7 +183,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab delete(last, valAddrStr) count++ - totalPower = totalPower.Add(sdk.NewInt(newPower)) + totalPower = totalPower.Add(sdkmath.NewInt(newPower)) } noLongerBonded, err := sortNoLongerBonded(last) diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index c4109a9f3ddf..9fa21a103124 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -371,11 +371,11 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { // first make sure everything made it in to the gotValidator group resValidators := app.StakingKeeper.GetBondedValidatorsByPower(ctx) assert.Equal(t, n, len(resValidators)) - assert.Equal(t, sdk.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdk.NewInt(100).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[2].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdk.NewInt(1).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[3].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdk.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(100).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[2].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(1).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[3].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators) assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[1].OperatorAddress, resValidators[2].OperatorAddress, "%v", resValidators) @@ -383,14 +383,14 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.Equal(t, validators[0].OperatorAddress, resValidators[4].OperatorAddress, "%v", resValidators) // test a basic increase in voting power - validators[3].Tokens = sdk.NewInt(500).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdkmath.NewInt(500).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) assert.True(ValEq(t, validators[3], resValidators[0])) // test a decrease in voting power - validators[3].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) @@ -398,7 +398,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.True(ValEq(t, validators[4], resValidators[1])) // test equal voting power, different age - validators[3].Tokens = sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)) ctx = ctx.WithBlockHeight(10) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) @@ -415,8 +415,8 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.True(ValEq(t, validators[4], resValidators[1])) // change in voting power of both validators, both still in v-set, no age change - validators[3].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) - validators[4].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[4].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) @@ -481,8 +481,8 @@ func TestGetValidatorSortingMixed(t *testing.T) { resValidators := app.StakingKeeper.GetBondedValidatorsByPower(ctx) // The validators returned should match the max validators assert.Equal(t, 2, len(resValidators)) - assert.Equal(t, sdk.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators) } @@ -585,10 +585,10 @@ func TestGetValidatorsEdgeCases(t *testing.T) { // validator 3 does not get spot back app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, validators[3]) - validators[3], _ = validators[3].AddTokensFromDel(sdk.NewInt(200)) + validators[3], _ = validators[3].AddTokensFromDel(sdkmath.NewInt(200)) notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdkmath.NewInt(200))))) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) @@ -943,7 +943,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { // zero power valPubKey := PKs[len(validators)+1] valAddr := sdk.ValAddress(valPubKey.Address().Bytes()) - amt := sdk.NewInt(100) + amt := sdkmath.NewInt(100) validator := teststaking.NewValidator(t, valAddr, valPubKey) validator, _ = validator.AddTokensFromDel(amt) diff --git a/x/staking/simulation/genesis.go b/x/staking/simulation/genesis.go index f8737f7f7e0a..38c02069286e 100644 --- a/x/staking/simulation/genesis.go +++ b/x/staking/simulation/genesis.go @@ -89,7 +89,7 @@ func RandomizedGenState(simState *module.SimulationState) { if err != nil { panic(err) } - validator.Tokens = sdk.NewInt(simState.InitialStake) + validator.Tokens = sdkmath.NewInt(simState.InitialStake) validator.DelegatorShares = sdk.NewDec(simState.InitialStake) validator.Commission = commission diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index 2c04abe875a8..b501a1ec2e22 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -6,12 +6,13 @@ import ( "testing" "time" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -322,7 +323,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) diff --git a/x/staking/types/delegation_test.go b/x/staking/types/delegation_test.go index 7ca5e8132eb4..813d5d068b43 100644 --- a/x/staking/types/delegation_test.go +++ b/x/staking/types/delegation_test.go @@ -33,7 +33,7 @@ func TestDelegationString(t *testing.T) { func TestUnbondingDelegationEqual(t *testing.T) { ubd1 := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, - time.Unix(0, 0), sdk.NewInt(0)) + time.Unix(0, 0), sdkmath.NewInt(0)) ubd2 := ubd1 ok := ubd1.String() == ubd2.String() @@ -48,17 +48,17 @@ func TestUnbondingDelegationEqual(t *testing.T) { func TestUnbondingDelegationString(t *testing.T) { ubd := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, - time.Unix(0, 0), sdk.NewInt(0)) + time.Unix(0, 0), sdkmath.NewInt(0)) require.NotEmpty(t, ubd.String()) } func TestRedelegationEqual(t *testing.T) { r1 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdk.NewInt(0), + time.Unix(0, 0), sdkmath.NewInt(0), sdk.NewDec(0)) r2 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdk.NewInt(0), + time.Unix(0, 0), sdkmath.NewInt(0), sdk.NewDec(0)) ok := r1.String() == r2.String() @@ -73,7 +73,7 @@ func TestRedelegationEqual(t *testing.T) { func TestRedelegationString(t *testing.T) { r := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdk.NewInt(0), + time.Unix(0, 0), sdkmath.NewInt(0), sdk.NewDec(10)) require.NotEmpty(t, r.String()) @@ -82,9 +82,9 @@ func TestRedelegationString(t *testing.T) { func TestDelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() dr1 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) + sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5))) dr2 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) + sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5))) drs := types.DelegationResponses{dr1, dr2} bz1, err := json.Marshal(dr1) @@ -111,8 +111,8 @@ func TestDelegationResponses(t *testing.T) { func TestRedelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() entries := []types.RedelegationEntryResponse{ - types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), - types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdkmath.NewInt(5), sdkmath.NewInt(5)), + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdkmath.NewInt(5), sdkmath.NewInt(5)), } rdr1 := types.NewRedelegationResponse(sdk.AccAddress(valAddr1), valAddr2, valAddr3, entries) rdr2 := types.NewRedelegationResponse(sdk.AccAddress(valAddr2), valAddr1, valAddr3, entries) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index f1ba552d9115..6830fdc5569d 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -73,7 +73,7 @@ func TestMsgCreateValidator(t *testing.T) { {"empty bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, coinZero, false}, {"nil bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, sdk.Coin{}, false}, {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdk.ZeroInt(), valAddr1, pk1, coinPos, false}, - {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdk.NewInt(-1), valAddr1, pk1, coinPos, false}, + {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdkmath.NewInt(-1), valAddr1, pk1, coinPos, false}, {"delegation less than min self delegation", "a", "b", "c", "d", "e", commission1, coinPos.Amount.Add(sdk.OneInt()), valAddr1, pk1, coinPos, false}, } diff --git a/x/staking/types/params.go b/x/staking/types/params.go index cb9def63e00e..ca84b7fb8021 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -211,7 +211,7 @@ func ValidatePowerReduction(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.LT(sdk.NewInt(1)) { + if v.LT(sdkmath.NewInt(1)) { return fmt.Errorf("power reduction cannot be lower than 1") } diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 8601fbeec723..8e14398da17b 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -78,7 +78,7 @@ func TestShareTokens(t *testing.T) { validator := mkValidator(100, sdk.NewDec(100)) assert.True(sdk.DecEq(t, sdk.NewDec(50), validator.TokensFromShares(sdk.NewDec(50)))) - validator.Tokens = sdk.NewInt(50) + validator.Tokens = sdkmath.NewInt(50) assert.True(sdk.DecEq(t, sdk.NewDec(25), validator.TokensFromShares(sdk.NewDec(50)))) assert.True(sdk.DecEq(t, sdk.NewDec(5), validator.TokensFromShares(sdk.NewDec(10)))) } @@ -87,36 +87,36 @@ func TestRemoveTokens(t *testing.T) { validator := mkValidator(100, sdk.NewDec(100)) // remove tokens and test check everything - validator = validator.RemoveTokens(sdk.NewInt(10)) + validator = validator.RemoveTokens(sdkmath.NewInt(10)) require.Equal(t, int64(90), validator.Tokens.Int64()) // update validator to from bonded -> unbonded validator = validator.UpdateStatus(types.Unbonded) require.Equal(t, types.Unbonded, validator.Status) - validator = validator.RemoveTokens(sdk.NewInt(10)) - require.Panics(t, func() { validator.RemoveTokens(sdk.NewInt(-1)) }) - require.Panics(t, func() { validator.RemoveTokens(sdk.NewInt(100)) }) + validator = validator.RemoveTokens(sdkmath.NewInt(10)) + require.Panics(t, func() { validator.RemoveTokens(sdkmath.NewInt(-1)) }) + require.Panics(t, func() { validator.RemoveTokens(sdkmath.NewInt(100)) }) } func TestAddTokensValidatorBonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Bonded) - validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.BondedTokens())) + assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.BondedTokens())) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } func TestAddTokensValidatorUnbonding(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Unbonding) - validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonding, validator.Status) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) + assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -124,11 +124,11 @@ func TestAddTokensValidatorUnbonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Unbonded) - validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonded, validator.Status) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) + assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -138,7 +138,7 @@ func TestRemoveDelShares(t *testing.T) { OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, Status: types.Bonded, - Tokens: sdk.NewInt(100), + Tokens: sdkmath.NewInt(100), DelegatorShares: sdk.NewDec(100), } @@ -152,26 +152,26 @@ func TestRemoveDelShares(t *testing.T) { validator := mkValidator(5102, sdk.NewDec(115)) _, tokens := validator.RemoveDelShares(sdk.NewDec(29)) - require.True(sdk.IntEq(t, sdk.NewInt(1286), tokens)) + require.True(sdk.IntEq(t, sdkmath.NewInt(1286), tokens)) } func TestAddTokensFromDel(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator, shares := validator.AddTokensFromDel(sdk.NewInt(6)) + validator, shares := validator.AddTokensFromDel(sdkmath.NewInt(6)) require.True(sdk.DecEq(t, sdk.NewDec(6), shares)) require.True(sdk.DecEq(t, sdk.NewDec(6), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdk.NewInt(6), validator.Tokens)) + require.True(sdk.IntEq(t, sdkmath.NewInt(6), validator.Tokens)) - validator, shares = validator.AddTokensFromDel(sdk.NewInt(3)) + validator, shares = validator.AddTokensFromDel(sdkmath.NewInt(3)) require.True(sdk.DecEq(t, sdk.NewDec(3), shares)) require.True(sdk.DecEq(t, sdk.NewDec(9), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdk.NewInt(9), validator.Tokens)) + require.True(sdk.IntEq(t, sdkmath.NewInt(9), validator.Tokens)) } func TestUpdateStatus(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator, _ = validator.AddTokensFromDel(sdk.NewInt(100)) + validator, _ = validator.AddTokensFromDel(sdkmath.NewInt(100)) require.Equal(t, types.Unbonded, validator.Status) require.Equal(t, int64(100), validator.Tokens.Int64()) @@ -191,7 +191,7 @@ func TestUpdateStatus(t *testing.T) { func TestPossibleOverflow(t *testing.T) { delShares := sdk.NewDec(391432570689183511).Quo(sdk.NewDec(40113011844664)) validator := mkValidator(2159, delShares) - newValidator, _ := validator.AddTokensFromDel(sdk.NewInt(71)) + newValidator, _ := validator.AddTokensFromDel(sdkmath.NewInt(71)) require.False(t, newValidator.DelegatorShares.IsNegative()) require.False(t, newValidator.Tokens.IsNegative()) @@ -280,11 +280,11 @@ func TestValidatorsSortTendermint(t *testing.T) { pk2 := ed25519.GenPrivKey().PubKey() vals[i] = newValidator(t, sdk.ValAddress(pk2.Address()), pk) vals[i].Status = types.Bonded - vals[i].Tokens = sdk.NewInt(rand.Int63()) + vals[i].Tokens = sdkmath.NewInt(rand.Int63()) } // create some validators with the same power for i := 0; i < 10; i++ { - vals[i].Tokens = sdk.NewInt(1000000) + vals[i].Tokens = sdkmath.NewInt(1000000) } valz := types.Validators(vals) @@ -312,7 +312,7 @@ func TestValidatorToTm(t *testing.T) { pk := ed25519.GenPrivKey().PubKey() val := newValidator(t, sdk.ValAddress(pk.Address()), pk) val.Status = types.Bonded - val.Tokens = sdk.NewInt(rand.Int63()) + val.Tokens = sdkmath.NewInt(rand.Int63()) vals[i] = val tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) require.NoError(t, err) @@ -339,7 +339,7 @@ func mkValidator(tokens int64, shares sdk.Dec) types.Validator { OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, Status: types.Bonded, - Tokens: sdk.NewInt(tokens), + Tokens: sdkmath.NewInt(tokens), DelegatorShares: shares, } } diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index a91b0b748d21..dd9f4cec3952 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -42,7 +42,7 @@ func (s *KeeperTestSuite) SetupTest() { Height: 10, }) s.msgSrvr = keeper.NewMsgServerImpl(s.app.UpgradeKeeper) - s.addrs = simapp.AddTestAddrsIncremental(app, s.ctx, 1, sdk.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, s.ctx, 1, sdkmath.NewInt(30000000)) } func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() { From 69981e321ae5f5bc2dbd82f51621f108fb900624 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:06:52 -0400 Subject: [PATCH 10/22] updates --- x/auth/middleware/middleware_test.go | 6 +++--- x/auth/tx/aux_test.go | 3 ++- x/auth/vesting/client/testutil/suite.go | 1 + x/auth/vesting/types/vesting_account.go | 9 ++++---- x/bank/client/testutil/grpc.go | 2 +- x/bank/client/testutil/suite.go | 4 ++-- x/bank/keeper/grpc_query.go | 2 +- x/bank/keeper/view.go | 2 +- x/distribution/keeper/delegation_test.go | 2 +- x/distribution/keeper/keeper.go | 2 +- x/distribution/keeper/keeper_test.go | 2 +- x/gov/types/v1/tally.go | 2 +- x/gov/types/v1beta1/tally.go | 2 +- x/slashing/app_test.go | 2 +- x/staking/app_test.go | 2 +- x/staking/genesis.go | 4 ++-- x/staking/genesis_test.go | 2 +- x/staking/keeper/delegation.go | 2 +- x/staking/keeper/delegation_test.go | 18 ++++++++-------- x/staking/keeper/invariants.go | 4 ++-- x/staking/keeper/keeper.go | 5 +++-- x/staking/keeper/slash.go | 14 ++++++------- x/staking/keeper/slash_test.go | 26 ++++++++++++------------ x/staking/keeper/val_state_change.go | 4 ++-- x/staking/keeper/validator_test.go | 10 ++++----- x/staking/types/keys_test.go | 2 +- x/staking/types/msg_test.go | 2 +- x/staking/types/validator.go | 6 +++--- x/staking/types/validator_test.go | 12 +++++------ 29 files changed, 79 insertions(+), 75 deletions(-) diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index b89d10c58d85..2c8b0c3be548 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -491,7 +491,7 @@ func (s *MWTestSuite) TestTxHandlerFees() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) s.Require().True(s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).Empty()) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(149))) + require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(149))) err := testutil.FundAccount(s.app.BankKeeper, ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) s.Require().NoError(err) @@ -505,8 +505,8 @@ func (s *MWTestSuite) TestTxHandlerFees() { func() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdkmath.NewInt(150))) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(0))) + require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdkmath.NewInt(150))) + require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(0))) }, false, false, diff --git a/x/auth/tx/aux_test.go b/x/auth/tx/aux_test.go index 7e60300ed13f..626593bf0bb9 100644 --- a/x/auth/tx/aux_test.go +++ b/x/auth/tx/aux_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" clienttx "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +25,7 @@ var ( msg = testdata.NewTestMsg(tipperAddr, aux2Addr) memo = "test-memo" - tip = &txtypes.Tip{Tipper: tipperAddr.String(), Amount: sdk.NewCoins(sdk.NewCoin("tip-denom", sdk.NewIntFromUint64(123)))} + tip = &txtypes.Tip{Tipper: tipperAddr.String(), Amount: sdk.NewCoins(sdk.NewCoin("tip-denom", sdkmath.NewIntFromUint64(123)))} chainID = "test-chain" gas = testdata.NewTestGasLimit() fee = testdata.NewTestFeeAmount() diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index 378a6226d927..302c2de6159b 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client/flags" + sdkmath "github.com/cosmos/cosmos-sdk/math" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 7316e6afd5b7..999f46c42f17 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -7,6 +7,7 @@ import ( "sigs.k8s.io/yaml" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" @@ -69,7 +70,7 @@ func (bva *BaseVestingAccount) TrackDelegation(balance, vestingCoins, amount sdk // compute x and y per the specification, where: // X := min(max(V - DV, 0), D) // Y := D - X - x := sdk.MinInt(sdk.MaxInt(vestingAmt.Sub(delVestingAmt), sdk.ZeroInt()), coin.Amount) + x := sdkmath.MinInt(sdkmath.MaxInt(vestingAmt.Sub(delVestingAmt), sdkmath.ZeroInt()), coin.Amount) y := coin.Amount.Sub(x) if !x.IsZero() { @@ -106,8 +107,8 @@ func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins) { // compute x and y per the specification, where: // X := min(DF, D) // Y := min(DV, D - X) - x := sdk.MinInt(delegatedFree, coin.Amount) - y := sdk.MinInt(delegatedVesting, coin.Amount.Sub(x)) + x := sdkmath.MinInt(delegatedFree, coin.Amount) + y := sdkmath.MinInt(delegatedVesting, coin.Amount.Sub(x)) if !x.IsZero() { xCoin := sdk.NewCoin(coin.Denom, x) @@ -238,7 +239,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin s := sdk.NewDec(x).Quo(sdk.NewDec(y)) for _, ovc := range cva.OriginalVesting { - vestedAmt := ovc.Amount.ToDec().Mul(s).RoundInt() + vestedAmt := sdk.ToDec(ovc.Amount).Mul(s).RoundInt() vestedCoins = append(vestedCoins, sdk.NewCoin(ovc.Denom, vestedAmt)) } diff --git a/x/bank/client/testutil/grpc.go b/x/bank/client/testutil/grpc.go index 3a91ff26ad99..8178414dde9c 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/testutil/grpc.go @@ -82,7 +82,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin("foobar", sdk.ZeroInt()), + Amount: sdk.NewCoin("foobar", sdkmath.ZeroInt()), }, }, } diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 178297a7f1a1..0edfed780d8b 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -141,7 +141,7 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() { }, false, &sdk.Coin{}, - NewCoin("foobar", sdk.ZeroInt()), + NewCoin("foobar", sdkmath.ZeroInt()), }, } @@ -211,7 +211,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { respType: &sdk.Coin{}, expected: &sdk.Coin{ Denom: "foobar", - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), }, }, } diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 032e9e5ecfff..6608a26103ea 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -91,7 +91,7 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend balances := sdk.NewCoins() accountStore := k.getAccountStore(sdkCtx, addr) - zeroAmt := sdk.ZeroInt() + zeroAmt := sdkmath.ZeroInt() pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index cf66c1962002..be846ca70350 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -98,7 +98,7 @@ func (k BaseViewKeeper) GetAccountsBalances(ctx sdk.Context) []types.Balance { // by address. func (k BaseViewKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { accountStore := k.getAccountStore(ctx, addr) - amount := sdk.ZeroInt() + amount := sdkmath.ZeroInt() bz := accountStore.Get([]byte(denom)) if bz == nil { return sdk.NewCoin(denom, amount) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 511ebafe6fdc..0b4184f7973a 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -688,7 +688,7 @@ func Test100PercentCommissionReward(t *testing.T) { zeroRewards := sdk.Coins{ sdk.Coin{ Denom: denom, - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), }, } require.True(t, rewards.IsEqual(zeroRewards)) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 50536b2698e8..fc458bc82bd2 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -101,7 +101,7 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres baseDenom, _ := sdk.GetBaseDenom() rewards = sdk.Coins{sdk.Coin{ Denom: baseDenom, - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), }} } diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 0c91f107c8f0..a9551db6f249 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -115,7 +115,7 @@ func TestFundCommunityPool(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, types.InitialFeePool()) - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.ZeroInt()) + addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.ZeroInt()) amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr[0], amount)) diff --git a/x/gov/types/v1/tally.go b/x/gov/types/v1/tally.go index cadb33f024e8..594e4c94d2cf 100644 --- a/x/gov/types/v1/tally.go +++ b/x/gov/types/v1/tally.go @@ -48,7 +48,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) + return NewTallyResult(sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt()) } // Equals returns if two tally results are equal. diff --git a/x/gov/types/v1beta1/tally.go b/x/gov/types/v1beta1/tally.go index c0f09a88ba0b..0fba2c9fc2c1 100644 --- a/x/gov/types/v1beta1/tally.go +++ b/x/gov/types/v1beta1/tally.go @@ -50,7 +50,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) + return NewTallyResult(sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt()) } // Equals returns if two proposals are equal. diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index e9ece2c690a1..065046a81da7 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -80,7 +80,7 @@ func TestSlashingMsgs(t *testing.T) { validator := checkValidator(t, app, addr1, true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, stakingtypes.Bonded, validator.Status) - require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(sdkmath.IntEq(t, bondTokens, validator.BondedTokens())) unjailMsg := &types.MsgUnjail{ValidatorAddr: sdk.ValAddress(addr1).String()} checkValidatorSigningInfo(t, app, sdk.ConsAddress(valAddr), true) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index a97954254826..b389a73cb47f 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -82,7 +82,7 @@ func TestStakingMsgs(t *testing.T) { validator := checkValidator(t, app, sdk.ValAddress(addr1), true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, types.Bonded, validator.Status) - require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(sdkmath.IntEq(t, bondTokens, validator.BondedTokens())) header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) diff --git a/x/staking/genesis.go b/x/staking/genesis.go index c019359c3526..42a9eef2cc5c 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -21,8 +21,8 @@ func InitGenesis( ctx sdk.Context, keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, data *types.GenesisState, ) (res []abci.ValidatorUpdate) { - bondedTokens := sdk.ZeroInt() - notBondedTokens := sdk.ZeroInt() + bondedTokens := sdkmath.ZeroInt() + notBondedTokens := sdkmath.ZeroInt() // We need to pretend to be "n blocks before genesis", where "n" is the // validator update delay, so that e.g. slashing periods are correctly diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index e8a933bc77d2..579fb2f3de55 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -170,7 +170,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { validators := make([]types.Validator, size) var err error - bondedPoolAmt := sdk.ZeroInt() + bondedPoolAmt := sdkmath.ZeroInt() for i := range validators { validators[i], err = types.NewValidator(sdk.ValAddress(addrs[i]), PKs[i], types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", "")) diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 097c3b037e95..c12596d485c8 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -192,7 +192,7 @@ func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64 // GetDelegatorUnbonding returns the total amount a delegator has unbonding. func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int { - unbonding := sdk.ZeroInt() + unbonding := sdkmath.ZeroInt() k.IterateDelegatorUnbondingDelegations(ctx, delegator, func(ubd types.UnbondingDelegation) bool { for _, entry := range ubd.Entries { unbonding = unbonding.Add(entry.Balance) diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index ada6a4ce2487..60ee0ea40c35 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -256,7 +256,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { require.Equal(t, startTokens, issuedShares.RoundInt()) validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true) - require.True(sdk.IntEq(t, startTokens, validator.BondedTokens())) + require.True(sdkmath.IntEq(t, startTokens, validator.BondedTokens())) require.True(t, validator.IsBonded()) delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) @@ -277,8 +277,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) + require.True(sdkmath.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) + require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) oldBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -290,8 +290,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded)) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded)) + require.True(sdkmath.IntEq(t, newBonded, oldBonded)) + require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded)) // mature unbonding delegations ctx = ctx.WithBlockTime(completionTime) @@ -300,8 +300,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded)) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) + require.True(sdkmath.IntEq(t, newBonded, oldBonded)) + require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -311,8 +311,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(1))) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) + require.True(sdkmath.IntEq(t, newBonded, oldBonded.SubRaw(1))) + require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) } //// test undelegating self delegation from a validator pushing it below MinSelfDelegation diff --git a/x/staking/keeper/invariants.go b/x/staking/keeper/invariants.go index ed88ec62518e..55cfda81f5b7 100644 --- a/x/staking/keeper/invariants.go +++ b/x/staking/keeper/invariants.go @@ -46,8 +46,8 @@ func AllInvariants(k Keeper) sdk.Invariant { // reflects the tokens actively bonded and not bonded func ModuleAccountInvariants(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - bonded := sdk.ZeroInt() - notBonded := sdk.ZeroInt() + bonded := sdkmath.ZeroInt() + notBonded := sdkmath.ZeroInt() bondedPool := k.GetBondedPool(ctx) notBondedPool := k.GetNotBondedPool(ctx) bondDenom := k.BondDenom(ctx) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 5dde8f1bb92a..49854b741d94 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -3,9 +3,10 @@ package keeper import ( "fmt" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -79,7 +80,7 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) sdk.Int { bz := store.Get(types.LastTotalPowerKey) if bz == nil { - return sdk.ZeroInt() + return sdkmath.ZeroInt() } ip := sdk.IntProto{} diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index a15cdfbfc711..c89f02dc0b76 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -103,8 +103,8 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh } // cannot decrease balance below zero - tokensToBurn := sdk.MinInt(remainingSlashAmount, validator.Tokens) - tokensToBurn = sdk.MaxInt(tokensToBurn, sdk.ZeroInt()) // defensive. + tokensToBurn := sdkmath.MinInt(remainingSlashAmount, validator.Tokens) + tokensToBurn = sdkmath.MaxInt(tokensToBurn, sdkmath.ZeroInt()) // defensive. // we need to calculate the *effective* slash fraction for distribution if validator.Tokens.IsPositive() { @@ -167,8 +167,8 @@ func (k Keeper) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) { func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation types.UnbondingDelegation, infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdk.ZeroInt() - burnedAmount := sdk.ZeroInt() + totalSlashAmount = sdkmath.ZeroInt() + burnedAmount := sdkmath.ZeroInt() // perform slashing on all entries within the unbonding delegation for i, entry := range unbondingDelegation.Entries { @@ -191,7 +191,7 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty // Possible since the unbonding delegation may already // have been slashed, and slash amounts are calculated // according to stake held at time of infraction - unbondingSlashAmount := sdk.MinInt(slashAmount, entry.Balance) + unbondingSlashAmount := sdkmath.MinInt(slashAmount, entry.Balance) // Update unbonding delegation if necessary if unbondingSlashAmount.IsZero() { @@ -220,8 +220,8 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, redelegation types.Redelegation, infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdk.ZeroInt() - bondedBurnedAmount, notBondedBurnedAmount := sdk.ZeroInt(), sdk.ZeroInt() + totalSlashAmount = sdkmath.ZeroInt() + bondedBurnedAmount, notBondedBurnedAmount := sdkmath.ZeroInt(), sdkmath.ZeroInt() // perform slashing on all entries within the redelegation for _, entry := range redelegation.Entries { diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 704197317c96..68bb0af91623 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -423,10 +423,10 @@ func TestSlashWithRedelegation(t *testing.T) { // burn bonded tokens from only from delegations bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -455,14 +455,14 @@ func TestSlashWithRedelegation(t *testing.T) { // seven bonded tokens burned bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -490,9 +490,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -520,9 +520,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded, bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded, bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) // read updating redelegation rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -590,10 +590,10 @@ func TestSlashBoth(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) + require.True(sdkmath.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) // read updating redelegation rdA, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -611,7 +611,7 @@ func TestSlashAmount(t *testing.T) { consAddr := sdk.ConsAddress(PKs[0].Address()) fraction := sdk.NewDecWithPrec(5, 1) burnedCoins := app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction) - require.True(t, burnedCoins.GT(sdk.ZeroInt())) + require.True(t, burnedCoins.GT(sdkmath.ZeroInt())) // test the case where the validator was not found, which should return no coins _, addrVals := generateAddresses(app, ctx, 100) diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index afddade3f540..ca87967726a6 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -113,8 +113,8 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab params := k.GetParams(ctx) maxValidators := params.MaxValidators powerReduction := k.PowerReduction(ctx) - totalPower := sdk.ZeroInt() - amtFromBondedToNotBonded, amtFromNotBondedToBonded := sdk.ZeroInt(), sdk.ZeroInt() + totalPower := sdkmath.ZeroInt() + amtFromBondedToNotBonded, amtFromNotBondedToBonded := sdkmath.ZeroInt(), sdkmath.ZeroInt() // Retrieve the last validator set. // The persistent set is updated later in this function. diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index 9fa21a103124..a16a811d1d6c 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -258,7 +258,7 @@ func TestValidatorBasics(t *testing.T) { for i, power := range powers { validators[i] = teststaking.NewValidator(t, addrVals[i], PKs[i]) validators[i].Status = types.Unbonded - validators[i].Tokens = sdk.ZeroInt() + validators[i].Tokens = sdkmath.ZeroInt() tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power) validators[i], _ = validators[i].AddTokensFromDel(tokens) @@ -295,7 +295,7 @@ func TestValidatorBasics(t *testing.T) { require.Equal(t, 1, len(resVals)) assert.True(ValEq(t, validators[0], resVals[0])) assert.Equal(t, types.Bonded, validators[0].Status) - assert.True(sdk.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) + assert.True(sdkmath.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) // modify a records, save, and retrieve validators[0].Status = types.Bonded @@ -340,7 +340,7 @@ func TestValidatorBasics(t *testing.T) { "attempting to remove a validator which still contains tokens", func() { app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) }) - validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens + validators[1].Tokens = sdkmath.ZeroInt() // ...remove all tokens app.StakingKeeper.SetValidator(ctx, validators[1]) // ...set the validator app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) // Now it can be removed. _, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) @@ -353,7 +353,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { // initialize some validators into the state amts := []sdk.Int{ - sdk.NewIntFromUint64(0), + sdkmath.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), @@ -446,7 +446,7 @@ func TestGetValidatorSortingMixed(t *testing.T) { // initialize some validators into the state amts := []sdk.Int{ - sdk.NewIntFromUint64(0), + sdkmath.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 35667f949da5..02026d2ccf80 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -26,7 +26,7 @@ var ( func TestGetValidatorPowerRank(t *testing.T) { valAddr1 := sdk.ValAddress(keysAddr1) val1 := newValidator(t, valAddr1, keysPK1) - val1.Tokens = sdk.ZeroInt() + val1.Tokens = sdkmath.ZeroInt() val2, val3, val4 := val1, val1, val1 val2.Tokens = sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction) val3.Tokens = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 6830fdc5569d..8fd2ca25741a 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -72,7 +72,7 @@ func TestMsgCreateValidator(t *testing.T) { {"empty pubkey", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, emptyPubkey, coinPos, false}, {"empty bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, coinZero, false}, {"nil bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, sdk.Coin{}, false}, - {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdk.ZeroInt(), valAddr1, pk1, coinPos, false}, + {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdkmath.ZeroInt(), valAddr1, pk1, coinPos, false}, {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdkmath.NewInt(-1), valAddr1, pk1, coinPos, false}, {"delegation less than min self delegation", "a", "b", "c", "d", "e", commission1, coinPos.Amount.Add(sdk.OneInt()), valAddr1, pk1, coinPos, false}, } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 79bd2a4f55b1..23ae1a3ec1b0 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -50,7 +50,7 @@ func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, descriptio ConsensusPubkey: pkAny, Jailed: false, Status: Unbonded, - Tokens: sdk.ZeroInt(), + Tokens: sdkmath.ZeroInt(), DelegatorShares: sdk.ZeroDec(), Description: description, UnbondingHeight: int64(0), @@ -351,7 +351,7 @@ func (v Validator) BondedTokens() sdk.Int { return v.Tokens } - return sdk.ZeroInt() + return sdkmath.ZeroInt() } // ConsensusPower gets the consensus-engine power. Aa reduction of 10^6 from @@ -423,7 +423,7 @@ func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) { if remainingShares.IsZero() { // last delegation share gets any trimmings issuedTokens = v.Tokens - v.Tokens = sdk.ZeroInt() + v.Tokens = sdkmath.ZeroInt() } else { // leave excess tokens in the validator // however fully use all the delegator shares diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 8e14398da17b..1929c1d53f77 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -105,7 +105,7 @@ func TestAddTokensValidatorBonded(t *testing.T) { validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.BondedTokens())) + assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.BondedTokens())) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -116,7 +116,7 @@ func TestAddTokensValidatorUnbonding(t *testing.T) { assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonding, validator.Status) - assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) + assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -128,7 +128,7 @@ func TestAddTokensValidatorUnbonded(t *testing.T) { assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonded, validator.Status) - assert.True(sdk.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) + assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -152,7 +152,7 @@ func TestRemoveDelShares(t *testing.T) { validator := mkValidator(5102, sdk.NewDec(115)) _, tokens := validator.RemoveDelShares(sdk.NewDec(29)) - require.True(sdk.IntEq(t, sdkmath.NewInt(1286), tokens)) + require.True(sdkmath.IntEq(t, sdkmath.NewInt(1286), tokens)) } func TestAddTokensFromDel(t *testing.T) { @@ -161,12 +161,12 @@ func TestAddTokensFromDel(t *testing.T) { validator, shares := validator.AddTokensFromDel(sdkmath.NewInt(6)) require.True(sdk.DecEq(t, sdk.NewDec(6), shares)) require.True(sdk.DecEq(t, sdk.NewDec(6), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdkmath.NewInt(6), validator.Tokens)) + require.True(sdkmath.IntEq(t, sdkmath.NewInt(6), validator.Tokens)) validator, shares = validator.AddTokensFromDel(sdkmath.NewInt(3)) require.True(sdk.DecEq(t, sdk.NewDec(3), shares)) require.True(sdk.DecEq(t, sdk.NewDec(9), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdkmath.NewInt(9), validator.Tokens)) + require.True(sdkmath.IntEq(t, sdkmath.NewInt(9), validator.Tokens)) } func TestUpdateStatus(t *testing.T) { From cdf9d59d64daca2dfd0c364afb9075d909ea5168 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:12:16 -0400 Subject: [PATCH 11/22] updates --- x/auth/client/testutil/suite.go | 61 +++++---- x/auth/middleware/branch_store_test.go | 3 +- x/auth/middleware/fee_test.go | 9 +- x/auth/middleware/feegrant_test.go | 5 +- x/auth/middleware/middleware_test.go | 12 +- x/auth/middleware/tips_test.go | 11 +- x/auth/migrations/legacytx/stdtx_test.go | 3 +- x/auth/migrations/v043/store_test.go | 121 +++++++++--------- x/auth/module.go | 6 - x/auth/tx/aux_test.go | 3 +- x/auth/tx/builder_test.go | 3 +- x/auth/tx/service_test.go | 13 +- x/auth/vesting/client/testutil/suite.go | 19 ++- x/auth/vesting/module.go | 5 - x/auth/vesting/types/vesting_account.go | 9 +- x/authz/client/testutil/grpc.go | 2 +- x/authz/client/testutil/query.go | 4 +- x/authz/client/testutil/tx.go | 104 +++++++-------- x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/keeper_test.go | 2 +- x/authz/module/abci_test.go | 7 +- x/authz/module/module.go | 5 - x/authz/msgs_test.go | 7 +- x/authz/simulation/genesis.go | 2 +- x/bank/client/testutil/grpc.go | 12 +- x/bank/client/testutil/suite.go | 38 +++--- x/bank/keeper/genesis_test.go | 10 +- x/bank/keeper/grpc_query.go | 2 +- x/bank/keeper/keeper.go | 2 +- x/bank/keeper/keeper_test.go | 8 +- x/bank/keeper/view.go | 2 +- x/bank/migrations/v043/json_test.go | 14 +- x/bank/migrations/v043/store_test.go | 10 +- x/bank/migrations/v046/store_test.go | 4 +- x/bank/module.go | 6 - x/bank/simulation/genesis.go | 4 +- x/bank/types/balance_test.go | 2 +- x/bank/types/send_authorization_test.go | 4 +- x/capability/module.go | 5 - x/crisis/client/testsuite/suite.go | 6 +- x/crisis/module.go | 5 - x/crisis/types/genesis.go | 2 +- x/distribution/client/testutil/suite.go | 30 ++--- .../client/testutil/withdraw_all_suite.go | 19 ++- x/distribution/keeper/allocation_test.go | 22 ++-- x/distribution/keeper/delegation_test.go | 36 +++--- x/distribution/keeper/grpc_query_test.go | 4 +- x/distribution/keeper/keeper.go | 2 +- x/distribution/keeper/keeper_test.go | 12 +- x/distribution/keeper/querier_test.go | 4 +- x/distribution/module.go | 6 - x/distribution/proposal_handler_test.go | 2 +- x/distribution/simulation/operations_test.go | 6 +- x/distribution/simulation/proposals_test.go | 2 +- x/evidence/module.go | 6 - x/feegrant/client/testutil/suite.go | 22 ++-- x/feegrant/keeper/genesis_test.go | 2 +- x/feegrant/keeper/keeper_test.go | 4 +- x/feegrant/migrations/v046/store_test.go | 5 +- x/feegrant/module/abci_test.go | 11 +- x/feegrant/module/module.go | 5 - x/feegrant/msgs_test.go | 2 +- x/feegrant/simulation/decoder_test.go | 2 +- x/feegrant/simulation/genesis.go | 4 +- x/genutil/client/testutil/suite.go | 2 +- x/genutil/module.go | 5 - x/gov/client/cli/parse_test.go | 6 +- x/gov/client/testutil/deposits.go | 6 +- x/gov/client/testutil/helpers.go | 2 +- x/gov/client/testutil/query.go | 4 +- x/gov/client/testutil/tx.go | 50 ++++---- x/gov/genesis_test.go | 2 +- x/gov/keeper/common_test.go | 4 +- x/gov/keeper/deposit_test.go | 2 +- x/gov/keeper/grpc_query_test.go | 14 +- x/gov/keeper/keeper_test.go | 4 +- x/gov/keeper/msg_server_test.go | 16 +-- x/gov/keeper/querier_test.go | 2 +- x/gov/keeper/tally_test.go | 2 +- x/gov/keeper/vote_test.go | 2 +- x/gov/migrations/v046/convert_test.go | 13 +- x/gov/migrations/v046/json_test.go | 2 +- x/gov/module.go | 6 - x/gov/types/v1/params.go | 2 +- x/gov/types/v1/tally.go | 2 +- x/gov/types/v1beta1/params.go | 2 +- x/gov/types/v1beta1/tally.go | 2 +- x/group/client/testutil/query.go | 2 +- x/group/client/testutil/tx.go | 38 +++--- x/group/keeper/grpc_query_test.go | 7 +- x/group/keeper/keeper_test.go | 4 +- x/group/module/abci_test.go | 9 +- x/group/module/module.go | 5 - x/mint/module.go | 6 - x/mint/types/minter.go | 2 +- x/mint/types/minter_test.go | 4 +- x/nft/client/testutil/tx.go | 6 +- x/nft/keeper/keeper_test.go | 2 +- x/nft/module/module.go | 5 - x/params/keeper/keeper_test.go | 2 +- x/params/module.go | 5 - x/params/proposal_handler_test.go | 2 +- x/slashing/app_test.go | 2 +- x/slashing/client/testutil/suite.go | 2 +- x/slashing/module.go | 6 - x/slashing/simulation/operations_test.go | 4 +- x/staking/app_test.go | 2 +- x/staking/bench_test.go | 2 +- x/staking/client/testutil/grpc.go | 6 +- x/staking/client/testutil/suite.go | 118 ++++++++--------- x/staking/client/testutil/test_helpers.go | 2 +- x/staking/genesis.go | 4 +- x/staking/genesis_test.go | 8 +- x/staking/keeper/common_test.go | 2 +- x/staking/keeper/delegation.go | 2 +- x/staking/keeper/delegation_test.go | 60 ++++----- x/staking/keeper/historical_info_test.go | 6 +- x/staking/keeper/invariants.go | 4 +- x/staking/keeper/keeper.go | 5 +- x/staking/keeper/msg_server_test.go | 11 +- x/staking/keeper/power_reduction_test.go | 4 +- x/staking/keeper/querier_test.go | 6 +- x/staking/keeper/slash.go | 16 +-- x/staking/keeper/slash_test.go | 58 ++++----- x/staking/keeper/val_state_change.go | 6 +- x/staking/keeper/validator_test.go | 40 +++--- x/staking/module.go | 6 - x/staking/simulation/genesis.go | 2 +- x/staking/simulation/operations_test.go | 5 +- x/staking/types/delegation_test.go | 18 +-- x/staking/types/keys_test.go | 2 +- x/staking/types/msg_test.go | 4 +- x/staking/types/params.go | 2 +- x/staking/types/validator.go | 6 +- x/staking/types/validator_test.go | 46 +++---- x/upgrade/keeper/keeper_test.go | 2 +- x/upgrade/module.go | 6 - 137 files changed, 682 insertions(+), 806 deletions(-) diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 5b6b7fdb37ae..40aa258dd5e6 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -20,7 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -87,8 +86,8 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestCLIValidateSignatures() { val := s.network.Validators[0] sendTokens := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))) + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))) res, err := s.createBankMsg(val, val.Address, sendTokens, fmt.Sprintf("--%s=true", flags.FlagGenerateOnly)) @@ -131,7 +130,7 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() { account, err := val.ClientCtx.AccountRetriever.GetAccount(val.ClientCtx, addr) s.Require().NoError(err) - sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))) + sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))) args := []string{ keyName, // from keyname val2.Address.String(), @@ -233,8 +232,8 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() { func (s *IntegrationTestSuite) TestCLISignBatch() { val := s.network.Validators[0] var sendTokens = sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ) generatedStd, err := s.createBankMsg(val, val.Address, @@ -286,8 +285,8 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() { val1 := s.network.Validators[0] txCfg := val1.ClientCtx.TxConfig var sendTokens = sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ) txBz, err := s.createBankMsg(val1, val1.Address, sendTokens, fmt.Sprintf("--%s=true", flags.FlagGenerateOnly)) @@ -605,7 +604,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { "fee event happy case", []string{ fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, @@ -614,7 +613,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { "no matching fee event", []string{ fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(0))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, true, @@ -820,7 +819,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -931,7 +930,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -997,7 +996,7 @@ func (s *IntegrationTestSuite) TestSignWithMultisig() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1058,7 +1057,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1132,11 +1131,11 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() { addr, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1194,11 +1193,11 @@ func (s *IntegrationTestSuite) TestMultisignBatch() { addr, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -1388,11 +1387,11 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { // Create a txBuilder with an unsigned tx. txBuilder := txCfg.NewTxBuilder() msg := banktypes.NewMsgSend(val1.Address, val1.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), )) err := txBuilder.SetMsgs(msg) s.Require().NoError(err) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)))) txBuilder.SetGasLimit(testdata.NewTestGasLimit()) // Set empty signature to set signer infos. sigV2 := signing.SignatureV2{ @@ -1443,8 +1442,8 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { require := s.Require() val0, val1 := s.network.Validators[0], s.network.Validators[1] - val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val0.Moniker), sdkmath.NewInt(10)) - val1Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdkmath.NewInt(10)) + val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val0.Moniker), sdk.NewInt(10)) + val1Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdk.NewInt(10)) _, _, addr1 := testdata.KeyTestPubAddr() // Creating a tx with 2 msgs from 2 signers: val0 and val1. @@ -1456,7 +1455,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { banktypes.NewMsgSend(val0.Address, addr1, sdk.NewCoins(val0Coin)), banktypes.NewMsgSend(val1.Address, addr1, sdk.NewCoins(val1Coin)), ) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)))) txBuilder.SetGasLimit(testdata.NewTestGasLimit() * 2) require.Equal([]sdk.AccAddress{val0.Address, val1.Address}, txBuilder.GetTx().GetSigners()) @@ -1509,7 +1508,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { func (s *IntegrationTestSuite) TestAuxSigner() { require := s.Require() val := s.network.Validators[0] - val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)) + val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)) testCases := []struct { name string @@ -1572,11 +1571,11 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipper, err := acc.GetAddress() require.NoError(err) - tipperInitialBal := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10000)) + tipperInitialBal := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10000)) feePayer := val.Address - fee := sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1000)) - tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(1000)) + fee := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000)) + tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(1000)) s.Require().NoError(s.network.WaitForNextBlock()) _, err = s.createBankMsg(val, tipper, sdk.NewCoins(tipperInitialBal)) @@ -1655,7 +1654,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "--tip flag unset: no error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), fmt.Sprintf("--%s=true", flags.FlagAux), @@ -1726,7 +1725,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "wrong denom in tip: error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, "1000wrongDenom"), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), @@ -1745,7 +1744,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { name: "insufficient fees: error", tipper: tipper, feePayer: feePayer, - tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdkmath.NewInt(0)}, + tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, tip), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), @@ -1817,7 +1816,7 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk. flags := []string{fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } flags = append(flags, extraFlags...) diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go index d7f24464ebb4..80e116fb2a82 100644 --- a/x/auth/middleware/branch_store_test.go +++ b/x/auth/middleware/branch_store_test.go @@ -6,7 +6,6 @@ import ( "math" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -38,7 +37,7 @@ func (s *MWTestSuite) TestBranchStore() { txBuilder := s.clientCtx.TxConfig.NewTxBuilder() // tx fee - feeCoin := sdk.NewCoin("atom", sdkmath.NewInt(150)) + feeCoin := sdk.NewCoin("atom", sdk.NewInt(150)) feeAmount := sdk.NewCoins(feeCoin) // test account and fund diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go index 30e35fcb58d7..9899e2aa63c3 100644 --- a/x/auth/middleware/fee_test.go +++ b/x/auth/middleware/fee_test.go @@ -2,7 +2,6 @@ package middleware_test import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" @@ -26,7 +25,7 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { // msg and signatures msg := testdata.NewTestMsg(addr1) - atomCoin := sdk.NewCoin("atom", sdkmath.NewInt(150)) + atomCoin := sdk.NewCoin("atom", sdk.NewInt(150)) apeCoin := sdk.NewInt64Coin("ape", 1500000) feeAmount := sdk.NewCoins(apeCoin, atomCoin) gasLimit := testdata.NewTestGasLimit() @@ -97,7 +96,7 @@ func (s *MWTestSuite) TestDeductFees() { // Set account with insufficient funds acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr1) s.app.AccountKeeper.SetAccount(ctx, acc) - coins := sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(10))) + coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10))) err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, coins) s.Require().NoError(err) @@ -111,14 +110,14 @@ func (s *MWTestSuite) TestDeductFees() { // Set account with sufficient funds s.app.AccountKeeper.SetAccount(ctx, acc) - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(200)))) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) s.Require().NoError(err) // DeliverTx _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) s.Require().Nil(err, "Tx did not error after account has been set with sufficient funds") - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(200)))) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) s.Require().NoError(err) // SimulateTx diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/middleware/feegrant_test.go index cfe3d478ff34..547f57a589d1 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/middleware/feegrant_test.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,11 +48,11 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { priv5, _, addr5 := testdata.KeyTestPubAddr() // Set addr1 with insufficient funds - err := testutil.FundAccount(s.app.BankKeeper, ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdkmath.NewInt(10))}) + err := testutil.FundAccount(s.app.BankKeeper, ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) s.Require().NoError(err) // Set addr2 with more funds - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdkmath.NewInt(99999))}) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) s.Require().NoError(err) // grant fee allowance from `addr2` to `addr3` (plenty to pay) diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index 2c8b0c3be548..d923b84b2c3d 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -7,14 +7,10 @@ import ( "strings" "testing" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -24,6 +20,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" ) var testCoins = sdk.Coins{sdk.NewInt64Coin("atom", 10000000)} @@ -491,7 +489,7 @@ func (s *MWTestSuite) TestTxHandlerFees() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) s.Require().True(s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).Empty()) - require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(149))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(149))) err := testutil.FundAccount(s.app.BankKeeper, ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) s.Require().NoError(err) @@ -505,8 +503,8 @@ func (s *MWTestSuite) TestTxHandlerFees() { func() { modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) - require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdkmath.NewInt(150))) - require.True(sdkmath.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdkmath.NewInt(0))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdk.NewInt(150))) + require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(0))) }, false, false, diff --git a/x/auth/middleware/tips_test.go b/x/auth/middleware/tips_test.go index f3ec2fc6c7c6..7fb50f7e0f0f 100644 --- a/x/auth/middleware/tips_test.go +++ b/x/auth/middleware/tips_test.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" clienttx "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -19,8 +18,8 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) -var initialRegens = sdk.NewCoins(sdk.NewCoin("regen", sdkmath.NewInt(1000))) -var initialAtoms = sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(1000))) +var initialRegens = sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(1000))) +var initialAtoms = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(1000))) // setupAcctsForTips sets up 2 accounts: // - tipper has 1000 regens @@ -62,17 +61,17 @@ func (s *MWTestSuite) TestTips() { }{ { "wrong tip denom", - sdk.NewCoins(sdk.NewCoin("foobar", sdkmath.NewInt(1000))), initialAtoms, 200000, + sdk.NewCoins(sdk.NewCoin("foobar", sdk.NewInt(1000))), initialAtoms, 200000, true, "0foobar is smaller than 1000foobar: insufficient funds", }, { "insufficient tip from tipper", - sdk.NewCoins(sdk.NewCoin("regen", sdkmath.NewInt(5000))), initialAtoms, 200000, + sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(5000))), initialAtoms, 200000, true, "1000regen is smaller than 5000regen: insufficient funds", }, { "insufficient fees from feePayer", - initialRegens, sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(5000))), 200000, + initialRegens, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(5000))), 200000, true, "1000atom is smaller than 5000atom: insufficient funds: insufficient funds", }, { diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index 5ca52abcf715..c883a2faa2ea 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -165,7 +164,7 @@ func TestTxValidateBasic(t *testing.T) { // require to fail validation upon invalid fee badFee := NewTestStdFee() - badFee.Amount[0].Amount = sdkmath.NewInt(-5) + badFee.Amount[0].Amount = sdk.NewInt(-5) tx := NewTestTx(ctx, nil, nil, nil, nil, 0, badFee) err := tx.ValidateBasic() diff --git a/x/auth/migrations/v043/store_test.go b/x/auth/migrations/v043/store_test.go index 7ca3925c41ee..cae87b96885c 100644 --- a/x/auth/migrations/v043/store_test.go +++ b/x/auth/migrations/v043/store_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -35,18 +34,18 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -60,14 +59,14 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -81,18 +80,18 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -106,12 +105,12 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -125,16 +124,16 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(200))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -147,16 +146,16 @@ func TestMigrateVestingAccounts(t *testing.T) { "not end time", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(100), stakingtypes.Unbonded, validator, true) + _, err = app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -169,12 +168,12 @@ func TestMigrateVestingAccounts(t *testing.T) { "delayed vesting has not vested, single delegation greater than the total account balance", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -188,14 +187,14 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -211,14 +210,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -234,14 +233,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -257,14 +256,14 @@ func TestMigrateVestingAccounts(t *testing.T) { startTime := ctx.BlockTime().AddDate(-2, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewContinuousVestingAccount(baseAccount, vestedCoins, startTime, endTime) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) app.AccountKeeper.SetAccount(ctx, delayedAccount) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -278,7 +277,7 @@ func TestMigrateVestingAccounts(t *testing.T) { func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(100))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(100))) start := ctx.BlockTime().Unix() + int64(time.Hour/time.Second) @@ -293,7 +292,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, account) - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(150), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(150), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -316,19 +315,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, } @@ -337,7 +336,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -360,19 +359,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, } @@ -383,7 +382,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -406,19 +405,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, } @@ -429,7 +428,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -452,19 +451,19 @@ func TestMigrateVestingAccounts(t *testing.T) { */ startTime := int64(1601042400) baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(3666666670000))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(3666666670000))) periods := []types.Period{ { Length: 31536000, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(1833333335000))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1833333335000))), }, { Length: 15638400, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, { Length: 15897600, - Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(916666667500))), + Amount: sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(916666667500))), }, } @@ -475,7 +474,7 @@ func TestMigrateVestingAccounts(t *testing.T) { app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(3666666670000), stakingtypes.Unbonded, validator, true) require.NoError(t, err) }, cleartTrackingFields, @@ -488,14 +487,14 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has unbonding delegations in place", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) app.AccountKeeper.SetAccount(ctx, delayedAccount) // delegation of the original vesting - _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdkmath.NewInt(300), stakingtypes.Unbonded, validator, true) + _, err := app.StakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(300), stakingtypes.Unbonded, validator, true) require.NoError(t, err) ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0)) @@ -504,7 +503,7 @@ func TestMigrateVestingAccounts(t *testing.T) { require.NoError(t, err) // un-delegation of the original vesting - _, err = app.StakingKeeper.Undelegate(ctx, delegatorAddr, valAddr, sdk.NewDecFromInt(sdkmath.NewInt(300))) + _, err = app.StakingKeeper.Undelegate(ctx, delegatorAddr, valAddr, sdk.NewDecFromInt(sdk.NewInt(300))) require.NoError(t, err) }, cleartTrackingFields, @@ -517,7 +516,7 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has never delegated anything", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) @@ -533,7 +532,7 @@ func TestMigrateVestingAccounts(t *testing.T) { "vesting account has no delegation but dirty DelegatedFree and DelegatedVesting fields", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) - vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(300))) + vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(10, 0, 0).Unix()) @@ -555,7 +554,7 @@ func TestMigrateVestingAccounts(t *testing.T) { Time: time.Now(), }) - addrs := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(tc.tokenAmount)) + addrs := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(tc.tokenAmount)) delegatorAddr := addrs[0] _, valAddr := createValidator(t, ctx, app, tc.tokenAmount*2) @@ -581,11 +580,11 @@ func TestMigrateVestingAccounts(t *testing.T) { var expFree sdk.Coins if tc.expVested != 0 { - expVested = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(tc.expVested))) + expVested = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(tc.expVested))) } if tc.expFree != 0 { - expFree = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(tc.expFree))) + expFree = sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(tc.expFree))) } trackingCorrected( diff --git a/x/auth/module.go b/x/auth/module.go index dfb125058bd9..58f567fa26cf 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -59,11 +58,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the auth module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/auth` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auth module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/auth/tx/aux_test.go b/x/auth/tx/aux_test.go index 626593bf0bb9..7e60300ed13f 100644 --- a/x/auth/tx/aux_test.go +++ b/x/auth/tx/aux_test.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" clienttx "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,7 +24,7 @@ var ( msg = testdata.NewTestMsg(tipperAddr, aux2Addr) memo = "test-memo" - tip = &txtypes.Tip{Tipper: tipperAddr.String(), Amount: sdk.NewCoins(sdk.NewCoin("tip-denom", sdkmath.NewIntFromUint64(123)))} + tip = &txtypes.Tip{Tipper: tipperAddr.String(), Amount: sdk.NewCoins(sdk.NewCoin("tip-denom", sdk.NewIntFromUint64(123)))} chainID = "test-chain" gas = testdata.NewTestGasLimit() fee = testdata.NewTestFeeAmount() diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index c8d055bf5ba4..f7122dd39218 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -136,7 +135,7 @@ func TestBuilderValidateBasic(t *testing.T) { // require to fail validation upon invalid fee badFeeAmount := testdata.NewTestFeeAmount() - badFeeAmount[0].Amount = sdkmath.NewInt(-5) + badFeeAmount[0].Amount = sdk.NewInt(-5) txBuilder := newBuilder(nil) var sig1, sig2 signing.SignatureV2 diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index d02fd0160d55..28481c57c38c 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -17,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/rest" @@ -70,11 +69,11 @@ func (s *IntegrationTestSuite) SetupSuite() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) @@ -87,12 +86,12 @@ func (s *IntegrationTestSuite) SetupSuite() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1)), ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=2", flags.FlagSequence), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) @@ -552,7 +551,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() { sdk.NewCoins(coins), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), ) @@ -570,7 +569,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() { ), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=foobar", flags.FlagNote), ) diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index 302c2de6159b..7f56de2c1cc2 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client/flags" - sdkmath "github.com/cosmos/cosmos-sdk/math" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" @@ -53,12 +52,12 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "create a continuous vesting account": { args: []string{ sdk.AccAddress("addr2_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -67,13 +66,13 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "create a delayed vesting account": { args: []string{ sdk.AccAddress("addr3_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", cli.FlagDelayed), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -82,7 +81,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "invalid address": { args: []string{ "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, @@ -104,7 +103,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { "invalid end time": { args: []string{ sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), "-4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, @@ -160,11 +159,11 @@ func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { "create a permanent locked account": { args: []string{ sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, expectErr: false, expectedCode: 0, @@ -173,7 +172,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { "invalid address": { args: []string{ "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), "4070908800", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), }, diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 272ebf2656bf..49925dd61f2c 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -3,7 +3,6 @@ package vesting import ( "encoding/json" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -54,10 +53,6 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConf return nil } -// RegisterRESTRoutes registers the REST routes for the vesting module. Currently, this is a no-op. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the module's gRPC Gateway routes. Currently, this // is a no-op. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 999f46c42f17..7316e6afd5b7 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -7,7 +7,6 @@ import ( "sigs.k8s.io/yaml" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" @@ -70,7 +69,7 @@ func (bva *BaseVestingAccount) TrackDelegation(balance, vestingCoins, amount sdk // compute x and y per the specification, where: // X := min(max(V - DV, 0), D) // Y := D - X - x := sdkmath.MinInt(sdkmath.MaxInt(vestingAmt.Sub(delVestingAmt), sdkmath.ZeroInt()), coin.Amount) + x := sdk.MinInt(sdk.MaxInt(vestingAmt.Sub(delVestingAmt), sdk.ZeroInt()), coin.Amount) y := coin.Amount.Sub(x) if !x.IsZero() { @@ -107,8 +106,8 @@ func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins) { // compute x and y per the specification, where: // X := min(DF, D) // Y := min(DV, D - X) - x := sdkmath.MinInt(delegatedFree, coin.Amount) - y := sdkmath.MinInt(delegatedVesting, coin.Amount.Sub(x)) + x := sdk.MinInt(delegatedFree, coin.Amount) + y := sdk.MinInt(delegatedVesting, coin.Amount.Sub(x)) if !x.IsZero() { xCoin := sdk.NewCoin(coin.Denom, x) @@ -239,7 +238,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin s := sdk.NewDec(x).Quo(sdk.NewDec(y)) for _, ovc := range cva.OriginalVesting { - vestedAmt := sdk.ToDec(ovc.Amount).Mul(s).RoundInt() + vestedAmt := ovc.Amount.ToDec().Mul(s).RoundInt() vestedCoins = append(vestedCoins, sdk.NewCoin(ovc.Denom, vestedAmt)) } diff --git a/x/authz/client/testutil/grpc.go b/x/authz/client/testutil/grpc.go index ee90de6ce3bf..6cf5e65ab76a 100644 --- a/x/authz/client/testutil/grpc.go +++ b/x/authz/client/testutil/grpc.go @@ -115,7 +115,7 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { fmt.Sprintf("--%s=%s", cli.FlagMsgType, typeMsgVote), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 69ccc07ae708..56296576507b 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -30,7 +30,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -108,7 +108,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index 24bed9faa50c..da1cf903ed60 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -73,7 +73,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) @@ -93,7 +93,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), }) s.Require().NoError(err) @@ -127,9 +127,9 @@ func (s *IntegrationTestSuite) msgSendExec(grantee sdk.AccAddress) { val.ClientCtx, val.Address, grantee, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) s.Require().NoError(err) s.Require().Contains(out.String(), `"code":0`) @@ -205,7 +205,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), }, 0x1d, @@ -223,7 +223,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, true, @@ -239,7 +239,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -255,7 +255,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -271,7 +271,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -287,7 +287,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -302,7 +302,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -317,7 +317,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, false, @@ -332,7 +332,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, 0, true, @@ -347,7 +347,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, 0, @@ -397,7 +397,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -413,7 +413,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -429,7 +429,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, ) @@ -474,7 +474,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, &sdk.TxResponse{}, 0, false, @@ -487,7 +487,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, &sdk.TxResponse{}, 0, false, @@ -500,7 +500,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, &sdk.TxResponse{}, 0, @@ -542,7 +542,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, tenSeconds), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -560,7 +560,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }) s.Require().NoError(err) @@ -582,7 +582,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -627,7 +627,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, &sdk.TxResponse{}, @@ -640,7 +640,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -685,12 +685,12 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(12)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(12)), ) normalGeneratedTx, err := banktestutil.MsgSendExec( val.ClientCtx, @@ -699,7 +699,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { tokens, fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), ) s.Require().NoError(err) @@ -717,7 +717,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -730,7 +730,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee1.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -743,7 +743,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -790,13 +790,13 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin("stake", sdkmath.NewInt(50)), + sdk.NewCoin("stake", sdk.NewInt(50)), ) delegateTx := fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -816,7 +816,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -829,7 +829,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -842,7 +842,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -881,12 +881,12 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens = sdk.NewCoins( - sdk.NewCoin("stake", sdkmath.NewInt(50)), + sdk.NewCoin("stake", sdk.NewInt(50)), ) delegateTx = fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -906,7 +906,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -919,7 +919,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -959,7 +959,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -968,7 +968,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { execMsg.Name(), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), } cmd := cli.NewCmdExecAuthorization() @@ -994,7 +994,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) @@ -1008,13 +1008,13 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens := sdk.NewCoins( - sdk.NewCoin("stake", sdkmath.NewInt(50)), + sdk.NewCoin("stake", sdk.NewInt(50)), ) undelegateTx := fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -1035,7 +1035,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1049,7 +1049,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1063,7 +1063,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, authz.ErrNoAuthorizationFound.ABCICode(), @@ -1102,12 +1102,12 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, ) s.Require().NoError(err) tokens = sdk.NewCoins( - sdk.NewCoin("stake", sdkmath.NewInt(50)), + sdk.NewCoin("stake", sdk.NewInt(50)), ) undelegateTx = fmt.Sprintf(`{"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"%s","validator_address":"%s","amount":{"denom":"%s","amount":"%s"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, val.Address.String(), val.ValAddress.String(), @@ -1128,7 +1128,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, @@ -1142,7 +1142,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagGas, "250000"), fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, 0, diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 59bdf14cc195..077d2a162bd1 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -37,7 +37,7 @@ var ( ) func (suite *GenesisTestSuite) TestImportExportGenesis() { - coins := sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(1_000))) + coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) now := suite.ctx.BlockTime() expires := now.Add(time.Hour) diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 170f6cf9c2ae..223e3ad32617 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -45,7 +45,7 @@ func (s *TestSuite) SetupTest() { s.app = app s.ctx = ctx s.queryClient = queryClient - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) } func (s *TestSuite) TestKeeper() { diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 04d234ec8676..5858476aeac5 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -4,21 +4,20 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestExpiredGrantsQueue(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, types.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) granter := addrs[0] grantee1 := addrs[1] grantee2 := addrs[2] diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 219969f34f36..7ff061c691f5 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -77,10 +76,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return authz.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the authz module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the authz module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)); err != nil { diff --git a/x/authz/msgs_test.go b/x/authz/msgs_test.go index fd62b5f5d2b4..7f85584121ed 100644 --- a/x/authz/msgs_test.go +++ b/x/authz/msgs_test.go @@ -1,11 +1,10 @@ package authz_test import ( + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" "time" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -152,11 +151,11 @@ func TestAminoJSON(t *testing.T) { require.NoError(t, err) grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt) require.NoError(t, err) - sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000)))), &expiresAt) + sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), &expiresAt) require.NoError(t, err) valAddr, err := sdk.ValAddressFromBech32("cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq") require.NoError(t, err) - stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdkmath.NewInt(1000)}) + stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000)}) require.NoError(t, err) delegateGrant, err := authz.NewGrant(blockTime, stakingAuth, nil) require.NoError(t, err) diff --git a/x/authz/simulation/genesis.go b/x/authz/simulation/genesis.go index cc976c34332a..8c4609b7bb5c 100644 --- a/x/authz/simulation/genesis.go +++ b/x/authz/simulation/genesis.go @@ -37,7 +37,7 @@ func genGrant(r *rand.Rand, accounts []simtypes.Account, genT time.Time) []authz func generateRandomGrant(r *rand.Rand) *codectypes.Any { authorizations := make([]*codectypes.Any, 2) - authorizations[0] = newAnyAuthorization(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))))) + authorizations[0] = newAnyAuthorization(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))))) authorizations[1] = newAnyAuthorization(authz.NewGenericAuthorization(sdk.MsgTypeURL(&v1.MsgSubmitProposal{}))) return authorizations[r.Intn(len(authorizations))] diff --git a/x/bank/client/testutil/grpc.go b/x/bank/client/testutil/grpc.go index 8178414dde9c..f09b26009011 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/testutil/grpc.go @@ -34,7 +34,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { &types.QueryTotalSupplyResponse{ Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), ), Pagination: &query.PageResponse{ Total: 2, @@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), }, }, { @@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(20))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(20))), }, }, { @@ -71,7 +71,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), }, }, { @@ -82,7 +82,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin("foobar", sdkmath.ZeroInt()), + Amount: sdk.NewCoin("foobar", sdk.ZeroInt()), }, }, } @@ -266,7 +266,7 @@ func (s *IntegrationTestSuite) TestBalancesGRPCHandler() { &types.QueryBalanceResponse{ Balance: &sdk.Coin{ Denom: "foobar", - Amount: sdkmath.NewInt(0), + Amount: sdk.NewInt(0), }, }, }, diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 0edfed780d8b..539dfc5f3039 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -141,7 +141,7 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() { }, false, &sdk.Coin{}, - NewCoin("foobar", sdkmath.ZeroInt()), + NewCoin("foobar", sdk.ZeroInt()), }, } @@ -183,7 +183,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { expected: &types.QueryTotalSupplyResponse{ Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdkmath.NewInt(10))), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), ), Pagination: &query.PageResponse{Total: 0}, }, @@ -198,7 +198,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { respType: &sdk.Coin{}, expected: &sdk.Coin{ Denom: s.cfg.BondDenom, - Amount: s.cfg.StakingTokens.Add(sdkmath.NewInt(10)), + Amount: s.cfg.StakingTokens.Add(sdk.NewInt(10)), }, }, { @@ -211,7 +211,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { respType: &sdk.Coin{}, expected: &sdk.Coin{ Denom: "foobar", - Amount: sdkmath.ZeroInt(), + Amount: sdk.ZeroInt(), }, }, } @@ -370,13 +370,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() { from := val.Address to := val.Address amount := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ) args := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), } @@ -404,13 +404,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -419,13 +419,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagOffline), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), }, @@ -436,13 +436,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(1))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1))).String()), }, false, sdkerrors.ErrInsufficientFee.ABCICode(), @@ -453,13 +453,13 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { val.Address, val.Address, sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdkmath.NewInt(10)), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)), + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ), []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), "--gas=10", }, false, diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 01c5bf0916b4..d8fd84d2e290 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -74,11 +74,11 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { // Prepare some test data. defaultGenesis := types.DefaultGenesisState() balances := []types.Balance{ - {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(1))), Address: "cosmos1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0556gh0"}, - {Coins: sdk.NewCoins(sdk.NewCoin("barcoin", sdkmath.NewInt(1))), Address: "cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd"}, - {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(10)), sdk.NewCoin("barcoin", sdkmath.NewInt(20))), Address: "cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q"}, + {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(1))), Address: "cosmos1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0556gh0"}, + {Coins: sdk.NewCoins(sdk.NewCoin("barcoin", sdk.NewInt(1))), Address: "cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd"}, + {Coins: sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(10)), sdk.NewCoin("barcoin", sdk.NewInt(20))), Address: "cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q"}, } - totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(11)), sdk.NewCoin("barcoin", sdkmath.NewInt(21))) + totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(11)), sdk.NewCoin("barcoin", sdk.NewInt(21))) genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) @@ -92,7 +92,7 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { }{ { "calculation NOT matching genesis Supply field", - types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdkmath.NewInt(1))), defaultGenesis.DenomMetadata), + types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdk.NewInt(1))), defaultGenesis.DenomMetadata), nil, true, "genesis supply is incorrect, expected 1wrongcoin, got 21barcoin,11foocoin", }, { diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 6608a26103ea..032e9e5ecfff 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -91,7 +91,7 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend balances := sdk.NewCoins() accountStore := k.getAccountStore(sdkCtx, addr) - zeroAmt := sdkmath.ZeroInt() + zeroAmt := sdk.ZeroInt() pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 36069ff2f82e..40492e33a358 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -225,7 +225,7 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { if bz == nil { return sdk.Coin{ Denom: denom, - Amount: sdkmath.NewInt(0), + Amount: sdk.NewInt(0), } } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 3a2718542155..7c3feb4c1c2f 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -228,7 +228,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck - err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdkmath.NewInt(-10)}}) + err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) suite.Require().Error(err, "insufficient coins") suite.Require().Panics(func() { keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck @@ -905,7 +905,7 @@ func (suite *IntegrationTestSuite) TestDelegateCoins_Invalid() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) - invalidCoins := sdk.Coins{sdk.Coin{Denom: "fooDenom", Amount: sdkmath.NewInt(-50)}} + invalidCoins := sdk.Coins{sdk.Coin{Denom: "fooDenom", Amount: sdk.NewInt(-50)}} suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, invalidCoins)) app.AccountKeeper.SetAccount(ctx, macc) @@ -1063,7 +1063,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.app.BankKeeper.MintCoins( suite.ctx, multiPermAcc.Name, - sdk.NewCoins(sdk.NewCoin("utxo", sdkmath.NewInt(100000)))), + sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(100000)))), ) // send coins to address addr1 := sdk.AccAddress("addr1_______________") @@ -1072,7 +1072,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.ctx, multiPermAcc.Name, addr1, - sdk.NewCoins(sdk.NewCoin("utxo", sdkmath.NewInt(50000))), + sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(50000))), ), ) diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index be846ca70350..cf66c1962002 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -98,7 +98,7 @@ func (k BaseViewKeeper) GetAccountsBalances(ctx sdk.Context) []types.Balance { // by address. func (k BaseViewKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { accountStore := k.getAccountStore(ctx, addr) - amount := sdkmath.ZeroInt() + amount := sdk.ZeroInt() bz := accountStore.Get([]byte(denom)) if bz == nil { return sdk.NewCoin(denom, amount) diff --git a/x/bank/migrations/v043/json_test.go b/x/bank/migrations/v043/json_test.go index 8bb0c332708b..709b39c02920 100644 --- a/x/bank/migrations/v043/json_test.go +++ b/x/bank/migrations/v043/json_test.go @@ -27,17 +27,17 @@ func TestMigrateJSON(t *testing.T) { { Address: voter.String(), Coins: sdk.Coins{ - sdk.NewCoin("foo", sdkmath.NewInt(10)), - sdk.NewCoin("bar", sdkmath.NewInt(20)), - sdk.NewCoin("foobar", sdkmath.NewInt(0)), + sdk.NewCoin("foo", sdk.NewInt(10)), + sdk.NewCoin("bar", sdk.NewInt(20)), + sdk.NewCoin("foobar", sdk.NewInt(0)), }, }, }, Supply: sdk.Coins{ - sdk.NewCoin("foo", sdkmath.NewInt(10)), - sdk.NewCoin("bar", sdkmath.NewInt(20)), - sdk.NewCoin("foobar", sdkmath.NewInt(0)), - sdk.NewCoin("barfoo", sdkmath.NewInt(0)), + sdk.NewCoin("foo", sdk.NewInt(10)), + sdk.NewCoin("bar", sdk.NewInt(20)), + sdk.NewCoin("foobar", sdk.NewInt(0)), + sdk.NewCoin("barfoo", sdk.NewInt(0)), }, } diff --git a/x/bank/migrations/v043/store_test.go b/x/bank/migrations/v043/store_test.go index 4d18c3610de6..04117b3c3b32 100644 --- a/x/bank/migrations/v043/store_test.go +++ b/x/bank/migrations/v043/store_test.go @@ -21,9 +21,9 @@ func TestSupplyMigration(t *testing.T) { ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) - oldFooCoin := sdk.NewCoin("foo", sdkmath.NewInt(100)) - oldBarCoin := sdk.NewCoin("bar", sdkmath.NewInt(200)) - oldFooBarCoin := sdk.NewCoin("foobar", sdkmath.NewInt(0)) // to ensure the zero denom coins pruned. + oldFooCoin := sdk.NewCoin("foo", sdk.NewInt(100)) + oldBarCoin := sdk.NewCoin("bar", sdk.NewInt(200)) + oldFooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) // to ensure the zero denom coins pruned. // Old supply was stored as a single blob under the `SupplyKey`. var oldSupply v042bank.SupplyI @@ -73,14 +73,14 @@ func TestBalanceKeysMigration(t *testing.T) { _, _, addr := testdata.KeyTestPubAddr() // set 10 foo coin - fooCoin := sdk.NewCoin("foo", sdkmath.NewInt(10)) + fooCoin := sdk.NewCoin("foo", sdk.NewInt(10)) oldFooKey := append(append(v042bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) fooBz, err := encCfg.Codec.Marshal(&fooCoin) require.NoError(t, err) store.Set(oldFooKey, fooBz) // set 0 foobar coin - fooBarCoin := sdk.NewCoin("foobar", sdkmath.NewInt(0)) + fooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) oldKeyFooBar := append(append(v042bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) fooBarBz, err := encCfg.Codec.Marshal(&fooBarCoin) require.NoError(t, err) diff --git a/x/bank/migrations/v046/store_test.go b/x/bank/migrations/v046/store_test.go index 4493cc405c2b..db44f2591fdc 100644 --- a/x/bank/migrations/v046/store_test.go +++ b/x/bank/migrations/v046/store_test.go @@ -25,8 +25,8 @@ func TestMigrateStore(t *testing.T) { prefixAccStore := prefix.NewStore(store, v043.CreateAccountBalancesPrefix(addr)) balances := sdk.NewCoins( - sdk.NewCoin("foo", sdkmath.NewInt(10000)), - sdk.NewCoin("bar", sdkmath.NewInt(20000)), + sdk.NewCoin("foo", sdk.NewInt(10000)), + sdk.NewCoin("bar", sdk.NewInt(20000)), ) for _, b := range balances { diff --git a/x/bank/module.go b/x/bank/module.go index bd809816a7a3..bfeee7eed6ba 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -7,7 +7,6 @@ import ( "math/rand" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -61,11 +60,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo return data.Validate() } -// RegisterRESTRoutes registers the REST routes for the bank module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/bank` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bank module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/bank/simulation/genesis.go b/x/bank/simulation/genesis.go index 282e69b5ab01..9031d0336451 100644 --- a/x/bank/simulation/genesis.go +++ b/x/bank/simulation/genesis.go @@ -43,7 +43,7 @@ func RandomGenesisBalances(simState *module.SimulationState) []types.Balance { for _, acc := range simState.Accounts { genesisBalances = append(genesisBalances, types.Balance{ Address: acc.Address.String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(simState.InitialStake))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(simState.InitialStake))), }) } @@ -65,7 +65,7 @@ func RandomizedGenState(simState *module.SimulationState) { ) numAccs := int64(len(simState.Accounts)) - totalSupply := sdkmath.NewInt(simState.InitialStake * (numAccs + simState.NumBonded)) + totalSupply := sdk.NewInt(simState.InitialStake * (numAccs + simState.NumBonded)) supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupply)) bankGenesis := types.GenesisState{ diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index c3f85498c6b8..10ee2a74bf6e 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -59,7 +59,7 @@ func TestBalanceValidate(t *testing.T) { bank.Balance{ Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", Coins: sdk.Coins{ - sdk.Coin{Denom: "uatom", Amount: sdkmath.NewInt(-1)}, + sdk.Coin{Denom: "uatom", Amount: sdk.NewInt(-1)}, }, }, true, diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index e281102c0c74..5e058317f1e9 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -12,8 +12,8 @@ import ( ) var ( - coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) - coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(500))) + coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) + coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(500))) fromAddr = sdk.AccAddress("_____from _____") toAddr = sdk.AccAddress("_______to________") ) diff --git a/x/capability/module.go b/x/capability/module.go index f8295948d9b7..e2ac1709795c 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -6,7 +6,6 @@ import ( "math/rand" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -68,10 +67,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return genState.Validate() } -// RegisterRESTRoutes registers the REST routes for the capability module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the capability module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) { } diff --git a/x/crisis/client/testsuite/suite.go b/x/crisis/client/testsuite/suite.go index 36dc879e48b8..c80679a2d4e6 100644 --- a/x/crisis/client/testsuite/suite.go +++ b/x/crisis/client/testsuite/suite.go @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -68,7 +68,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -79,7 +79,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/crisis/module.go b/x/crisis/module.go index 428e8adc1a05..7c058a4f22e0 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -60,10 +59,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(&data) } -// RegisterRESTRoutes registers REST routes for the crisis module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the capability module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} diff --git a/x/crisis/types/genesis.go b/x/crisis/types/genesis.go index 810e6e1e8573..f53099130277 100644 --- a/x/crisis/types/genesis.go +++ b/x/crisis/types/genesis.go @@ -16,7 +16,7 @@ func NewGenesisState(constantFee sdk.Coin) *GenesisState { // DefaultGenesisState creates a default GenesisState object func DefaultGenesisState() *GenesisState { return &GenesisState{ - ConstantFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), + ConstantFee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), } } diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index 1cffa69a0d3e..ac912952be25 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -470,7 +470,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, []string{}, }, @@ -481,7 +481,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -495,7 +495,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=true", cli.FlagCommission), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -568,7 +568,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, []string{}, }, @@ -578,7 +578,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", @@ -653,7 +653,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -664,7 +664,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -708,18 +708,18 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, { "valid transaction", []string{ - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))).String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -757,11 +757,11 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { }` // fund some tokens to the community pool - args := []string{sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))).String(), + args := []string{sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String())} + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String())} invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp) cmd := cli.NewFundCommunityPoolCmd() @@ -778,7 +778,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { "recipient": "%s", "amount": "%s", "deposit": "%s" -}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) +}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { @@ -795,7 +795,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -806,7 +806,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/distribution/client/testutil/withdraw_all_suite.go b/x/distribution/client/testutil/withdraw_all_suite.go index b0f96faf7d8a..7b459a4dfde1 100644 --- a/x/distribution/client/testutil/withdraw_all_suite.go +++ b/x/distribution/client/testutil/withdraw_all_suite.go @@ -4,8 +4,6 @@ import ( "fmt" "strings" - "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -15,6 +13,7 @@ import ( banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + "github.com/stretchr/testify/suite" ) type WithdrawAllTestSuite struct { @@ -63,20 +62,20 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) require.NoError(err) // delegate 500 tokens to validator1 args := []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(500)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(500)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } cmd := stakingcli.NewDelegateCmd() _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) @@ -85,11 +84,11 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { // delegate 500 tokens to validator2 args = []string{ val1.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(500)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(500)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) require.NoError(err) @@ -100,7 +99,7 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=1", cli.FlagMaxMessagesPerTx), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } cmd = cli.NewWithdrawAllRewardsCmd() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) @@ -114,7 +113,7 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() { fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=2", cli.FlagMaxMessagesPerTx), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } cmd = cli.NewWithdrawAllRewardsCmd() out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 7c9f97ddea53..d32b43690cac 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -20,13 +20,13 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 3, sdkmath.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), true) val := app.StakingKeeper.Validator(ctx, valAddrs[0]) // allocate tokens @@ -52,17 +52,17 @@ func TestAllocateTokensToManyValidators(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, disttypes.InitialFeePool()) - addrs := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) // create second validator with 0% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[1], valConsPk2, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true) abciValA := abci.Validator{ Address: valConsPk1.Address(), @@ -83,7 +83,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { require.True(t, app.DistrKeeper.GetValidatorCurrentRewards(ctx, valAddrs[1]).Rewards.IsZero()) // allocate tokens as if both had voted and second was proposer - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) feeCollector := app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) require.NotNil(t, feeCollector) @@ -126,21 +126,21 @@ func TestAllocateTokensTruncation(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, disttypes.InitialFeePool()) - addrs := simapp.AddTestAddrs(app, ctx, 3, sdkmath.NewInt(1234)) + addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) // create validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(110), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), true) // create second validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[1], valConsPk2, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true) // create third validator with 10% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[2], valConsPk3, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), true) abciValA := abci.Validator{ Address: valConsPk1.Address(), @@ -166,7 +166,7 @@ func TestAllocateTokensTruncation(t *testing.T) { require.True(t, app.DistrKeeper.GetValidatorCurrentRewards(ctx, valAddrs[1]).Rewards.IsZero()) // allocate tokens as if both had voted and second was proposer - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(634195840))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(634195840))) feeCollector := app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) require.NotNil(t, feeCollector) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 0b4184f7973a..a1916913c424 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -22,12 +22,12 @@ func TestCalculateRewardsBasic(t *testing.T) { tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) // end block to bond validator and start new block staking.EndBlocker(ctx, app.StakingKeeper) @@ -75,7 +75,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -139,7 +139,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission @@ -214,12 +214,12 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(100000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) // end block to bond validator staking.EndBlocker(ctx, app.StakingKeeper) @@ -238,7 +238,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { // second delegation tstaking.Ctx = ctx - tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdkmath.NewInt(100)) + tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100)) del2 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0]) // fetch updated validator @@ -280,7 +280,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { balancePower := int64(1000) balanceTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, balancePower) - addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -349,7 +349,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -418,7 +418,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // create validator with 50% commission @@ -494,20 +494,20 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) initial := int64(20) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))))) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))} // create validator with 50% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) // end block to bond validator staking.EndBlocker(ctx, app.StakingKeeper) @@ -526,7 +526,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx)) // second delegation - tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdkmath.NewInt(100)) + tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100)) // historical count should be 3 (second delegation init) require.Equal(t, uint64(3), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx)) @@ -639,20 +639,20 @@ func Test100PercentCommissionReward(t *testing.T) { ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) initial := int64(20) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))))) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))} // create validator with 100% commission tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(10, 1), sdk.NewDecWithPrec(10, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0]) // end block to bond validator @@ -688,7 +688,7 @@ func Test100PercentCommissionReward(t *testing.T) { zeroRewards := sdk.Coins{ sdk.Coin{ Denom: denom, - Amount: sdkmath.ZeroInt(), + Amount: sdk.ZeroInt(), }, } require.True(t, rewards.IsEqual(zeroRewards)) diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index 3799badc2a66..d51f4a28a0ba 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -41,7 +41,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.ctx = ctx suite.queryClient = queryClient - suite.addrs = simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + suite.addrs = simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) suite.valAddrs = simapp.ConvertAddrsToValAddrs(suite.addrs) } @@ -344,7 +344,7 @@ func (suite *KeeperTestSuite) TestGRPCDelegationRewards() { tstaking := teststaking.NewHelper(suite.T(), ctx, app.StakingKeeper) tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valAddrs[0], valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true) staking.EndBlocker(ctx, app.StakingKeeper) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index fc458bc82bd2..50536b2698e8 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -101,7 +101,7 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres baseDenom, _ := sdk.GetBaseDenom() rewards = sdk.Coins{sdk.Coin{ Denom: baseDenom, - Amount: sdkmath.ZeroInt(), + Amount: sdk.ZeroInt(), }} } diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index a9551db6f249..9895e420bf80 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -17,7 +17,7 @@ func TestSetWithdrawAddr(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) params := app.DistrKeeper.GetParams(ctx) params.WithdrawAddrEnabled = false @@ -44,12 +44,12 @@ func TestWithdrawValidatorCommission(t *testing.T) { sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))), } - addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) // set module account coins distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdkmath.NewInt(2)), sdk.NewCoin("stake", sdkmath.NewInt(2))) + coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdk.NewInt(2)), sdk.NewCoin("stake", sdk.NewInt(2))) require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), coins)) app.AccountKeeper.SetModuleAccount(ctx, distrAcc) @@ -73,7 +73,7 @@ func TestWithdrawValidatorCommission(t *testing.T) { // check balance increase balance = app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0])) require.Equal(t, sdk.NewCoins( - sdk.NewCoin("mytoken", sdkmath.NewInt(1)), + sdk.NewCoin("mytoken", sdk.NewInt(1)), sdk.NewCoin("stake", expTokens.AddRaw(1)), ), balance) @@ -96,7 +96,7 @@ func TestGetTotalRewards(t *testing.T) { sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))), } - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) app.DistrKeeper.SetValidatorOutstandingRewards(ctx, valAddrs[0], types.ValidatorOutstandingRewards{Rewards: valCommission}) @@ -115,7 +115,7 @@ func TestFundCommunityPool(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, types.InitialFeePool()) - addr := simapp.AddTestAddrs(app, ctx, 2, sdkmath.ZeroInt()) + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.ZeroInt()) amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr[0], amount)) diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index ea1060218fd8..9e1fe7cccce5 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -122,7 +122,7 @@ func TestQueries(t *testing.T) { // reset fee pool app.DistrKeeper.SetFeePool(ctx, types.InitialFeePool()) - addr := simapp.AddTestAddrs(app, ctx, 1, sdkmath.NewInt(1000000000)) + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) valOpAddr1 := valAddrs[0] @@ -175,7 +175,7 @@ func TestQueries(t *testing.T) { // test delegation rewards query tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valOpAddr1, valConsPk1, sdkmath.NewInt(100), true) + tstaking.CreateValidator(valOpAddr1, valConsPk1, sdk.NewInt(100), true) staking.EndBlocker(ctx, app.StakingKeeper) diff --git a/x/distribution/module.go b/x/distribution/module.go index 13cf674e3be0..e2f240b1edaf 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -61,11 +60,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return types.ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the distribution module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/distribution` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the distribution module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 7129310a29a7..24be6c98e5ae 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -18,7 +18,7 @@ var ( delPk1 = ed25519.GenPrivKey().PubKey() delAddr1 = sdk.AccAddress(delPk1.Address()) - amount = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))) + amount = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))) ) func testProposal(recipient sdk.AccAddress, amount sdk.Coins) *types.CommunityPoolSpendProposal { diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 5736844bc4f8..4d70aab2eacf 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -145,8 +145,8 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName // set module account coins distrAcc := suite.app.DistrKeeper.GetDistributionAccount(suite.ctx) suite.Require().NoError(testutil.FundModuleAccount(suite.app.BankKeeper, suite.ctx, distrAcc.GetName(), sdk.NewCoins( - sdk.NewCoin(tokenName, sdkmath.NewInt(10)), - sdk.NewCoin("stake", sdkmath.NewInt(5)), + sdk.NewCoin(tokenName, sdk.NewInt(10)), + sdk.NewCoin("stake", sdk.NewInt(5)), ))) suite.app.AccountKeeper.SetModuleAccount(suite.ctx, distrAcc) @@ -262,7 +262,7 @@ func (suite *SimTestSuite) getTestingValidator(accounts []simtypes.Account, comm validator, err = validator.SetInitialCommission(commission) require.NoError(err) validator.DelegatorShares = sdk.NewDec(100) - validator.Tokens = sdkmath.NewInt(1000000) + validator.Tokens = sdk.NewInt(1000000) suite.app.StakingKeeper.SetValidator(suite.ctx, validator) diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index c3faf32802c4..aec70fd832c4 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -34,7 +34,7 @@ func TestProposalContents(t *testing.T) { require.Equal(t, simulation.OpWeightSubmitCommunitySpendProposal, w0.AppParamsKey()) require.Equal(t, simappparams.DefaultWeightTextProposal, w0.DefaultWeight()) - amount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)), sdk.NewCoin("atoken", sdkmath.NewInt(2))) + amount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), sdk.NewCoin("atoken", sdk.NewInt(2))) feePool := app.DistrKeeper.GetFeePool(ctx) feePool.CommunityPool = sdk.NewDecCoinsFromCoins(amount...) diff --git a/x/evidence/module.go b/x/evidence/module.go index 2d65ef8ead8a..0dcf1ac3fac3 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -71,11 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return gs.Validate() } -// RegisterRESTRoutes registers the evidence module's REST service handlers. -// Deprecated: RegisterRESTRoutes is deprecated. `x/evidence` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the evidence module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index 335ee867eaad..5423a18e9503 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.createGrant(granter, grantee) grant, err := feegrant.NewGrant(granter, grantee, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))), }) s.Require().NoError(err) @@ -83,10 +83,10 @@ func (s *IntegrationTestSuite) createGrant(granter, grantee sdk.Address) { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), } - fee := sdk.NewCoin("stake", sdkmath.NewInt(100)) + fee := sdk.NewCoin("stake", sdk.NewInt(100)) args := append( []string{ @@ -323,7 +323,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } testCases := []struct { @@ -614,7 +614,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } // Create new fee grant specifically to test amino. @@ -727,10 +727,10 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } - fee := sdk.NewCoin("stake", sdkmath.NewInt(100)) + fee := sdk.NewCoin("stake", sdk.NewInt(100)) args := append( []string{ @@ -778,9 +778,9 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), } - spendLimit := sdk.NewCoin("stake", sdkmath.NewInt(1000)) + spendLimit := sdk.NewCoin("stake", sdk.NewInt(1000)) allowMsgs := strings.Join([]string{sdk.MsgTypeURL(&govv1beta1.MsgSubmitProposal{}), sdk.MsgTypeURL(&govv1.MsgVoteWeighted{})}, ",") @@ -895,7 +895,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { return govtestutil.MsgSubmitLegacyProposal(val.ClientCtx, grantee.String(), "Text Proposal", "No desc", govv1beta1.ProposalTypeText, fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), ) }, &sdk.TxResponse{}, @@ -906,7 +906,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { func() (testutil.BufferWriter, error) { return govtestutil.MsgVote(val.ClientCtx, grantee.String(), "0", "yes", fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter.String()), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), ) }, &sdk.TxResponse{}, diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go index c729f71ff50f..0c80780da57c 100644 --- a/x/feegrant/keeper/genesis_test.go +++ b/x/feegrant/keeper/genesis_test.go @@ -36,7 +36,7 @@ var ( ) func (suite *GenesisTestSuite) TestImportExportGenesis() { - coins := sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(1_000))) + coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) now := suite.ctx.BlockHeader().Time oneYear := now.AddDate(1, 0, 0) msgSrvr := keeper.NewMsgServerImpl(suite.keeper) diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 9adf84fa5461..933d85c7cefe 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -35,11 +35,11 @@ func (suite *KeeperTestSuite) SetupTest() { suite.app = app suite.sdkCtx = ctx - suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 4, sdkmath.NewInt(30000000)) + suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) suite.ctx = sdk.WrapSDKContext(ctx) suite.keeper = suite.app.FeeGrantKeeper suite.msgSrvr = keeper.NewMsgServerImpl(suite.keeper) - suite.atom = sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(555))) + suite.atom = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(555))) } func (suite *KeeperTestSuite) TestKeeperCrud() { diff --git a/x/feegrant/migrations/v046/store_test.go b/x/feegrant/migrations/v046/store_test.go index b7fbcba049ff..5d7cb5d9d073 100644 --- a/x/feegrant/migrations/v046/store_test.go +++ b/x/feegrant/migrations/v046/store_test.go @@ -4,14 +4,13 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant" v046 "github.com/cosmos/cosmos-sdk/x/feegrant/migrations/v046" + "github.com/stretchr/testify/require" ) func TestMigration(t *testing.T) { @@ -24,7 +23,7 @@ func TestMigration(t *testing.T) { granter2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) grantee2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) now := ctx.BlockTime() oneDay := now.AddDate(0, 0, 1) twoDays := now.AddDate(0, 0, 2) diff --git a/x/feegrant/module/abci_test.go b/x/feegrant/module/abci_test.go index 8edd31b61c0b..4c8aa03d410e 100644 --- a/x/feegrant/module/abci_test.go +++ b/x/feegrant/module/abci_test.go @@ -3,27 +3,26 @@ package module_test import ( "testing" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestFeegrantPruning(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 4, sdkmath.NewInt(1000)) + addrs := simapp.AddTestAddrs(app, ctx, 4, sdk.NewInt(1000)) granter1 := addrs[0] granter2 := addrs[1] granter3 := addrs[2] grantee := addrs[3] - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) now := ctx.BlockTime() oneDay := now.AddDate(0, 0, 1) diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 2246de692456..6752b16f2331 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -86,10 +85,6 @@ func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.Tx return feegrant.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the feegrant module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feegrant module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := feegrant.RegisterQueryHandlerClient(context.Background(), mux, feegrant.NewQueryClient(clientCtx)); err != nil { diff --git a/x/feegrant/msgs_test.go b/x/feegrant/msgs_test.go index b40b5e846524..f33849557c97 100644 --- a/x/feegrant/msgs_test.go +++ b/x/feegrant/msgs_test.go @@ -137,7 +137,7 @@ func TestMsgRevokeAllowance(t *testing.T) { func TestAminoJSON(t *testing.T) { tx := legacytx.StdTx{} var msg legacytx.LegacyMsg - allowanceAny, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(100)))}) + allowanceAny, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)))}) require.NoError(t, err) // Amino JSON encoding has changed in feegrant since v0.46. diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 1cbf130489a4..bb6fc789d76b 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -26,7 +26,7 @@ func TestDecodeStore(t *testing.T) { dec := simulation.NewDecodeStore(cdc) grant, err := feegrant.NewGrant(granterAddr, granteeAddr, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))), }) require.NoError(t, err) diff --git a/x/feegrant/simulation/genesis.go b/x/feegrant/simulation/genesis.go index 3464bf692a89..7fbc8107c5bb 100644 --- a/x/feegrant/simulation/genesis.go +++ b/x/feegrant/simulation/genesis.go @@ -23,8 +23,8 @@ func genFeeGrants(r *rand.Rand, accounts []simtypes.Account) []feegrant.Grant { func generateRandomAllowances(granter, grantee sdk.AccAddress, r *rand.Rand) feegrant.Grant { allowances := make([]feegrant.Grant, 3) - spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) - periodSpendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(10))) + spendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) + periodSpendLimit := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))) basic := feegrant.BasicAllowance{ SpendLimit: spendLimit, diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index f1e0f26fb457..755d20154eb3 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestGenTxCmd() { val := s.network.Validators[0] clientCtx := val.ClientCtx - amount := sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(12)) + amount := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(12)) tests := []struct { name string diff --git a/x/genutil/module.go b/x/genutil/module.go index db3071ca00c7..9b91849b68c0 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -53,10 +52,6 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, txEncodingConfig cl return types.ValidateGenesis(&data, txEncodingConfig.TxJSONDecoder()) } -// RegisterRESTRoutes registers the REST routes for the genutil module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) { } diff --git a/x/gov/client/cli/parse_test.go b/x/gov/client/cli/parse_test.go index 18f514882568..e80c8c7c1a49 100644 --- a/x/gov/client/cli/parse_test.go +++ b/x/gov/client/cli/parse_test.go @@ -171,19 +171,19 @@ func TestParseSubmitProposal(t *testing.T) { // ok json msgs, metadata, deposit, err := parseSubmitProposal(cdc, okJSON.Name()) require.NoError(t, err, "unexpected error") - require.Equal(t, sdk.NewCoins(sdk.NewCoin("test", sdkmath.NewInt(1000))), deposit) + require.Equal(t, sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(1000))), deposit) require.Equal(t, base64.StdEncoding.EncodeToString(expectedMetadata), metadata) require.Len(t, msgs, 3) msg1, ok := msgs[0].(*banktypes.MsgSend) require.True(t, ok) require.Equal(t, addr.String(), msg1.FromAddress) require.Equal(t, addr.String(), msg1.ToAddress) - require.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(10))), msg1.Amount) + require.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))), msg1.Amount) msg2, ok := msgs[1].(*stakingtypes.MsgDelegate) require.True(t, ok) require.Equal(t, addr.String(), msg2.DelegatorAddress) require.Equal(t, addr.String(), msg2.ValidatorAddress) - require.Equal(t, sdk.NewCoin("stake", sdkmath.NewInt(10)), msg2.Amount) + require.Equal(t, sdk.NewCoin("stake", sdk.NewInt(10)), msg2.Amount) msg3, ok := msgs[2].(*v1.MsgExecLegacyContent) require.True(t, ok) require.Equal(t, addr.String(), msg3.Authority) diff --git a/x/gov/client/testutil/deposits.go b/x/gov/client/testutil/deposits.go index d2919eb0649e..8fc74ba1cdc8 100644 --- a/x/gov/client/testutil/deposits.go +++ b/x/gov/client/testutil/deposits.go @@ -41,8 +41,8 @@ func (s *DepositTestSuite) SetupSuite() { val := s.network.Validators[0] deposits := sdk.Coins{ - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(0)), - sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Sub(sdkmath.NewInt(50))), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0)), + sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Sub(sdk.NewInt(50))), } s.deposits = deposits @@ -99,7 +99,7 @@ func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() { proposalID := s.proposalIDs[0] // deposit amount - depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Add(sdkmath.NewInt(50))).String() + depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Add(sdk.NewInt(50))).String() _, err := MsgDeposit(clientCtx, val.Address.String(), proposalID, depositAmount) s.Require().NoError(err) diff --git a/x/gov/client/testutil/helpers.go b/x/gov/client/testutil/helpers.go index 8096be2f8b92..6dbb0d8722cb 100644 --- a/x/gov/client/testutil/helpers.go +++ b/x/gov/client/testutil/helpers.go @@ -14,7 +14,7 @@ import ( var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), } // MsgSubmitLegacyProposal creates a tx for submit legacy proposal diff --git a/x/gov/client/testutil/query.go b/x/gov/client/testutil/query.go index 1e4f0c05d96d..5f0502a8f039 100644 --- a/x/gov/client/testutil/query.go +++ b/x/gov/client/testutil/query.go @@ -177,7 +177,7 @@ func (s *IntegrationTestSuite) TestCmdTally() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - v1.NewTallyResult(sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0)), + v1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), }, { "json output", @@ -186,7 +186,7 @@ func (s *IntegrationTestSuite) TestCmdTally() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - v1.NewTallyResult(s.cfg.BondedTokens, sdkmath.NewInt(0), sdkmath.NewInt(0), sdkmath.NewInt(0)), + v1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), }, } diff --git a/x/gov/client/testutil/tx.go b/x/gov/client/testutil/tx.go index 606f988c01cf..f3f5a52c4913 100644 --- a/x/gov/client/testutil/tx.go +++ b/x/gov/client/testutil/tx.go @@ -110,7 +110,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { ], "metadata": "%s", "deposit": "%s" -}`, authtypes.NewModuleAddress(types.ModuleName), base64.StdEncoding.EncodeToString(propMetadata), sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) +}`, authtypes.NewModuleAddress(types.ModuleName), base64.StdEncoding.EncodeToString(propMetadata), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { @@ -125,7 +125,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { []string{ invalidPropFile.Name(), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -136,7 +136,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -176,7 +176,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { "description": "Hello, World!", "type": "Text", "deposit": "%s" -}`, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431))) +}`, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))) validPropFile := testutil.WriteToNewTempFile(s.T(), validProp) testCases := []struct { name string @@ -191,7 +191,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s=%s", cli.FlagProposal, invalidPropFile.Name()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -200,10 +200,10 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { []string{ fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), - fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)).String()), + fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -214,7 +214,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -224,11 +224,11 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), - fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5431)).String()), + fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -266,11 +266,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { { "without proposal id", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, }, @@ -281,7 +281,7 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, }, @@ -289,11 +289,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { "deposit on non existing proposal", []string{ "10", - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 2, }, @@ -301,11 +301,11 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { "deposit on non existing proposal", []string{ "1", - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), // 10stake + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, @@ -355,7 +355,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 2, }, @@ -367,7 +367,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, @@ -380,7 +380,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, @@ -428,7 +428,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 2, }, @@ -440,7 +440,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, @@ -453,7 +453,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--metadata=%s", "AQ=="), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, @@ -465,7 +465,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, }, @@ -477,7 +477,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, }, diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index b12bf5bbfd4b..72057751177e 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -130,7 +130,7 @@ func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { Amount: sdk.Coins{ sdk.NewCoin( "stake", - sdkmath.NewInt(1234), + sdk.NewInt(1234), ), }, }, diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index b258a5b5eb89..e5e5bf183109 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -31,13 +31,13 @@ func getTestProposal() []sdk.Msg { } return []sdk.Msg{ - banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000)))), + banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), legacyProposalMsg, } } func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress) { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(5) cdc := simapp.MakeTestEncodingConfig().Codec diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 9f70bed9eba4..8d0a1986aae0 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -14,7 +14,7 @@ func TestDeposits(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000000)) + TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 0f37e90f4923..14b4286eeb4e 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -588,7 +588,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryVote() { func (suite *KeeperTestSuite) TestGRPCQueryVotes() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) var ( req *v1.QueryVotesRequest @@ -689,7 +689,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() { func (suite *KeeperTestSuite) TestLegacyGRPCQueryVotes() { app, ctx, queryClient := suite.app, suite.ctx, suite.legacyQueryClient - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) var ( req *v1beta1.QueryVotesRequest @@ -1420,7 +1420,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() { expRes = &v1.QueryTallyResultResponse{ Tally: &v1.TallyResult{ - YesCount: sdkmath.NewInt(3 * 5 * 1000000).String(), + YesCount: sdk.NewInt(3 * 5 * 1000000).String(), NoCount: "0", AbstainCount: "0", NoWithVetoCount: "0", @@ -1531,10 +1531,10 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTally() { expRes = &v1beta1.QueryTallyResultResponse{ Tally: v1beta1.TallyResult{ - Yes: sdkmath.NewInt(3 * 5 * 1000000), - No: sdkmath.NewInt(0), - Abstain: sdkmath.NewInt(0), - NoWithVeto: sdkmath.NewInt(0), + Yes: sdk.NewInt(3 * 5 * 1000000), + No: sdk.NewInt(0), + Abstain: sdk.NewInt(0), + NoWithVeto: sdk.NewInt(0), }, } }, diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 188303689ca1..95daf0797e62 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) SetupTest() { // Populate the gov account with some coins, as the TestProposal we have // is a MsgSend from the gov account. - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100000))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100000))) err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) suite.NoError(err) err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, types.ModuleName, coins) @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) SetupTest() { govAcct := suite.app.GovKeeper.GetGovernanceAccount(suite.ctx).GetAddress() suite.legacyMsgSrvr = keeper.NewLegacyMsgServerImpl(govAcct.String(), suite.msgSrvr) - suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(30000000)) + suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000)) } func TestIncrementProposalNumber(t *testing.T) { diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 8634e3e14bdc..5bdd9951089e 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -15,7 +15,7 @@ func (suite *KeeperTestSuite) TestSubmitProposalReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) initialDeposit := coins minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestVoteReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -347,7 +347,7 @@ func (suite *KeeperTestSuite) TestDepositReq() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -415,7 +415,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgSubmitProposal() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) initialDeposit := coins minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit @@ -465,7 +465,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgVote() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -567,7 +567,7 @@ func (suite *KeeperTestSuite) TestLegacyVoteWeighted() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), @@ -670,7 +670,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { addrs := suite.addrs proposer := addrs[0] - coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))) minDeposit := suite.app.GovKeeper.GetDepositParams(suite.ctx).MinDeposit bankMsg := &banktypes.MsgSend{ FromAddress: govAcct.String(), diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index 083ccf08c582..54a3e9fec49a 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -151,7 +151,7 @@ func TestQueries(t *testing.T) { legacyQuerierCdc := app.LegacyAmino() querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(20000001)) + TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(20000001)) oneCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)) consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 106eb5b5b4d2..adb0d5a41609 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -41,7 +41,7 @@ func TestTallyNoQuorum(t *testing.T) { createValidators(t, ctx, app, []int64{2, 5, 0}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/keeper/vote_test.go b/x/gov/keeper/vote_test.go index 2c87f0f3f78d..a1723c0f45b5 100644 --- a/x/gov/keeper/vote_test.go +++ b/x/gov/keeper/vote_test.go @@ -15,7 +15,7 @@ func TestVotes(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "") diff --git a/x/gov/migrations/v046/convert_test.go b/x/gov/migrations/v046/convert_test.go index 1d370a3ed2d2..e8cbfedc2670 100644 --- a/x/gov/migrations/v046/convert_test.go +++ b/x/gov/migrations/v046/convert_test.go @@ -4,13 +4,12 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" v046 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/stretchr/testify/require" ) func TestConvertToLegacyProposal(t *testing.T) { @@ -57,10 +56,10 @@ func TestConvertToLegacyProposal(t *testing.T) { require.Equal(t, v1beta1Proposal.VotingEndTime, *proposal.VotingEndTime) require.Equal(t, v1beta1Proposal.SubmitTime, *proposal.SubmitTime) require.Equal(t, v1beta1Proposal.DepositEndTime, *proposal.DepositEndTime) - require.Equal(t, v1beta1Proposal.FinalTallyResult.Yes, sdkmath.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.No, sdkmath.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.NoWithVeto, sdkmath.NewInt(0)) - require.Equal(t, v1beta1Proposal.FinalTallyResult.Abstain, sdkmath.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Yes, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.No, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.NoWithVeto, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Abstain, sdk.NewInt(0)) } }) } @@ -165,7 +164,7 @@ func TestConvertToLegacyDeposit(t *testing.T) { deposit := v1.Deposit{ ProposalId: 1, Depositor: "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh", - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), } v1beta1Deposit := v046.ConvertToLegacyDeposit(&deposit) diff --git a/x/gov/migrations/v046/json_test.go b/x/gov/migrations/v046/json_test.go index 4f9b72d457dc..518161b9e8b5 100644 --- a/x/gov/migrations/v046/json_test.go +++ b/x/gov/migrations/v046/json_test.go @@ -43,7 +43,7 @@ func TestMigrateJSON(t *testing.T) { VotingEndTime: propTime, Status: v1beta1.StatusDepositPeriod, FinalTallyResult: v1beta1.EmptyTallyResult(), - TotalDeposit: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(123))), + TotalDeposit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(123))), }, } govGenState.Votes = v1beta1.Votes{ diff --git a/x/gov/module.go b/x/gov/module.go index 875c00437752..b93dab8f1f0a 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -8,7 +8,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -74,11 +73,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return v1.ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the gov module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/gov` legacy REST implementation -// has been removed from the SDK. -func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := v1.RegisterQueryHandlerClient(context.Background(), mux, v1.NewQueryClient(clientCtx)); err != nil { diff --git a/x/gov/types/v1/params.go b/x/gov/types/v1/params.go index 88a03e5f5585..b2321be75d55 100644 --- a/x/gov/types/v1/params.go +++ b/x/gov/types/v1/params.go @@ -16,7 +16,7 @@ const ( // Default governance params var ( - DefaultMinDepositTokens = sdkmath.NewInt(10000000) + DefaultMinDepositTokens = sdk.NewInt(10000000) DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3) diff --git a/x/gov/types/v1/tally.go b/x/gov/types/v1/tally.go index 594e4c94d2cf..cadb33f024e8 100644 --- a/x/gov/types/v1/tally.go +++ b/x/gov/types/v1/tally.go @@ -48,7 +48,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt()) + return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) } // Equals returns if two tally results are equal. diff --git a/x/gov/types/v1beta1/params.go b/x/gov/types/v1beta1/params.go index 449d337a80bd..98f9b0390cbd 100644 --- a/x/gov/types/v1beta1/params.go +++ b/x/gov/types/v1beta1/params.go @@ -16,7 +16,7 @@ const ( // Default governance params var ( - DefaultMinDepositTokens = sdkmath.NewInt(10000000) + DefaultMinDepositTokens = sdk.NewInt(10000000) DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3) diff --git a/x/gov/types/v1beta1/tally.go b/x/gov/types/v1beta1/tally.go index 0fba2c9fc2c1..c0f09a88ba0b 100644 --- a/x/gov/types/v1beta1/tally.go +++ b/x/gov/types/v1beta1/tally.go @@ -50,7 +50,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt()) + return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) } // Equals returns if two proposals are equal. diff --git a/x/group/client/testutil/query.go b/x/group/client/testutil/query.go index 27e697148ca6..5ca1c06e6932 100644 --- a/x/group/client/testutil/query.go +++ b/x/group/client/testutil/query.go @@ -773,7 +773,7 @@ func (s *IntegrationTestSuite) TestTallyResult() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } // create a proposal diff --git a/x/group/client/testutil/tx.go b/x/group/client/testutil/tx.go index 5c3c0d945b3c..a32c6b4206be 100644 --- a/x/group/client/testutil/tx.go +++ b/x/group/client/testutil/tx.go @@ -69,16 +69,16 @@ func (s *IntegrationTestSuite) SetupSuite() { val.ClientCtx, val.Address, account, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) s.Require().NoError(err) var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } memberWeight := "3" @@ -226,7 +226,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } validMembers := fmt.Sprintf(`{"members": [{ @@ -384,7 +384,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } groupIDs := make([]string, 2) @@ -510,7 +510,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } testCases := []struct { @@ -596,7 +596,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } validUpdatedMembersFileName := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ @@ -718,7 +718,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } validMembers := fmt.Sprintf(`{"members": [{ @@ -929,7 +929,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } groupID := s.group.Id @@ -1102,7 +1102,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyAdmin() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1206,7 +1206,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyDecisionPolicy() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1355,7 +1355,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyMetadata() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), } @@ -1472,7 +1472,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } testCases := []struct { @@ -1666,7 +1666,7 @@ func (s *IntegrationTestSuite) TestTxVote() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } ids := make([]string, 4) @@ -1859,7 +1859,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } ids := make([]string, 2) @@ -2007,7 +2007,7 @@ func (s *IntegrationTestSuite) TestTxExec() { var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } var proposalIDs []string @@ -2142,7 +2142,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { commonFlags := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } // create 3 accounts with some tokens @@ -2159,7 +2159,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { members[i-1] = account.String() _, err = banktestutil.MsgSendExec(clientCtx, val.Address, account, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(100))), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))), commonFlags..., ) require.NoError(err) @@ -2330,7 +2330,7 @@ func (s *IntegrationTestSuite) createCLIProposal(groupPolicyAddress, proposer, s msg := banktypes.MsgSend{ FromAddress: sendFrom, ToAddress: sendTo, - Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))), + Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))), } msgJSON, err := s.cfg.Codec.MarshalInterfaceJSON(&msg) s.Require().NoError(err) diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index 10da51d36b87..c9d91e728c26 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -4,13 +4,12 @@ import ( "context" "testing" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/group" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestQueryGroupsByMember(t *testing.T) { @@ -21,7 +20,7 @@ func TestQueryGroupsByMember(t *testing.T) { queryClient := group.NewQueryClient(queryHelper) sdkCtx := sdk.WrapSDKContext(ctx) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 6, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 6a9bdaad26ad..f5ef2c74fa68 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -48,7 +48,7 @@ func (s *TestSuite) SetupTest() { s.sdkCtx = ctx s.ctx = sdk.WrapSDKContext(ctx) s.keeper = s.app.GroupKeeper - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 6, sdkmath.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ @@ -2655,7 +2655,7 @@ func (s *TestSuite) TestProposalsByVPEnd() { } func (s *TestSuite) TestLeaveGroup() { - addrs := simapp.AddTestAddrsIncremental(s.app, s.sdkCtx, 7, sdkmath.NewInt(3000000)) + addrs := simapp.AddTestAddrsIncremental(s.app, s.sdkCtx, 7, sdk.NewInt(3000000)) admin1 := addrs[0] member1 := addrs[1] member2 := addrs[2] diff --git a/x/group/module/abci_test.go b/x/group/module/abci_test.go index ac477d2234ab..5f510c864ed2 100644 --- a/x/group/module/abci_test.go +++ b/x/group/module/abci_test.go @@ -5,15 +5,14 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/cosmos-sdk/x/group/module" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -21,7 +20,7 @@ import ( func TestEndBlockerPruning(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) addr1 := addrs[0] addr2 := addrs[1] addr3 := addrs[2] @@ -323,7 +322,7 @@ func TestEndBlockerTallying(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdkmath.NewInt(30000000)) + addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) // Initial group, group policy and balance setup members := []group.Member{ diff --git a/x/group/module/module.go b/x/group/module/module.go index 086728422ed4..7b8baf8538bf 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -97,10 +96,6 @@ func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // RegisterLegacyAminoCodec registers the group module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} -// RegisterRESTRoutes registers the REST routes for the group module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // Name returns the group module's name. func (AppModule) Name() string { return group.ModuleName diff --git a/x/mint/module.go b/x/mint/module.go index be5ba7fdf2f9..fc32ff67ff05 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -63,11 +62,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the mint module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/mint` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go index 63253a9f4cf5..3285d6ddf0e8 100644 --- a/x/mint/types/minter.go +++ b/x/mint/types/minter.go @@ -75,6 +75,6 @@ func (m Minter) NextAnnualProvisions(_ Params, totalSupply sdk.Int) sdk.Dec { // BlockProvision returns the provisions for a block based on the annual // provisions rate. func (m Minter) BlockProvision(params Params) sdk.Coin { - provisionAmt := m.AnnualProvisions.QuoInt(sdkmath.NewInt(int64(params.BlocksPerYear))) + provisionAmt := m.AnnualProvisions.QuoInt(sdk.NewInt(int64(params.BlocksPerYear))) return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt()) } diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index c0f03aa1bc94..4abedb51cd05 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -74,7 +74,7 @@ func TestBlockProvision(t *testing.T) { provisions := minter.BlockProvision(params) expProvisions := sdk.NewCoin(params.MintDenom, - sdkmath.NewInt(tc.expProvisions)) + sdk.NewInt(tc.expProvisions)) require.True(t, expProvisions.IsEqual(provisions), "test: %v\n\tExp: %v\n\tGot: %v\n", @@ -124,7 +124,7 @@ func BenchmarkNextAnnualProvisions(b *testing.B) { b.ReportAllocs() minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) params := DefaultParams() - totalSupply := sdkmath.NewInt(100000000000000) + totalSupply := sdk.NewInt(100000000000000) // run the NextAnnualProvisions function b.N times for n := 0; n < b.N; n++ { diff --git a/x/nft/client/testutil/tx.go b/x/nft/client/testutil/tx.go index 409493c0998f..e95bbf6b13d1 100644 --- a/x/nft/client/testutil/tx.go +++ b/x/nft/client/testutil/tx.go @@ -101,7 +101,7 @@ func (s *IntegrationTestSuite) TestCLITxSend() { fmt.Sprintf("--%s=%s", flags.FlagFrom, OwnerName), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } testCases := []struct { name string @@ -154,13 +154,13 @@ func (s *IntegrationTestSuite) initAccount() { args := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } s.owner, err = keyinfo.GetAddress() s.Require().NoError(err) - amount := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))) + amount := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))) _, err = banktestutil.MsgSendExec(ctx, val.Address, s.owner, amount, args...) s.Require().NoError(err) } diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go index 448c69c74baf..7e03f79eb582 100644 --- a/x/nft/keeper/keeper_test.go +++ b/x/nft/keeper/keeper_test.go @@ -45,7 +45,7 @@ func (s *TestSuite) SetupTest() { s.app = app s.ctx = ctx s.queryClient = queryClient - s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000)) } func TestTestSuite(t *testing.T) { diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 0b456e55c33c..ab6fc9633cc9 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -71,10 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return nft.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the nft module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, r *mux.Router) { -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the nft module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := nft.RegisterQueryHandlerClient(context.Background(), mux, nft.NewQueryClient(clientCtx)); err != nil { diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 3f8c187e4885..92e2afb9185e 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -181,7 +181,7 @@ func TestSubspace(t *testing.T) { {"uint16", uint16(1), uint16(0), new(uint16)}, {"uint32", uint32(1), uint32(0), new(uint32)}, {"uint64", uint64(1), uint64(0), new(uint64)}, - {"int", sdkmath.NewInt(1), *new(sdk.Int), new(sdk.Int)}, + {"int", sdk.NewInt(1), *new(sdk.Int), new(sdk.Int)}, {"uint", sdk.NewUint(1), *new(sdk.Uint), new(sdk.Uint)}, {"dec", sdk.NewDec(1), *new(sdk.Dec), new(sdk.Dec)}, {"struct", s{1}, s{0}, new(s)}, diff --git a/x/params/module.go b/x/params/module.go index f17ab2199d44..da4679f8789f 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -51,10 +50,6 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodin return nil } -// RegisterRESTRoutes registers the REST routes for the params module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the params module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := proposal.RegisterQueryHandlerClient(context.Background(), mux, proposal.NewQueryClient(clientCtx)); err != nil { diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index cd4f0938fa0a..7b4bb36d6307 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -72,7 +72,7 @@ func (suite *HandlerTestSuite) TestProposalHandler() { depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx) defaultPeriod := govv1.DefaultPeriod suite.Require().Equal(govv1.DepositParams{ - MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(64000000))), + MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))), MaxDepositPeriod: &defaultPeriod, }, depositParams) }, diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 065046a81da7..e9ece2c690a1 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -80,7 +80,7 @@ func TestSlashingMsgs(t *testing.T) { validator := checkValidator(t, app, addr1, true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, stakingtypes.Bonded, validator.Status) - require.True(sdkmath.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) unjailMsg := &types.MsgUnjail{ValidatorAddr: sdk.ValAddress(addr1).String()} checkValidatorSigningInfo(t, app, sdk.ConsAddress(valAddr), true) diff --git a/x/slashing/client/testutil/suite.go b/x/slashing/client/testutil/suite.go index 9fbd6ce3f5bf..06bcdca70110 100644 --- a/x/slashing/client/testutil/suite.go +++ b/x/slashing/client/testutil/suite.go @@ -157,7 +157,7 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, diff --git a/x/slashing/module.go b/x/slashing/module.go index cf51b57066ad..7627bbf3a0b9 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -68,11 +67,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the slashing module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/slashing` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the slashig module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index a191bfb79706..a0dbffb1f360 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -123,7 +123,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -163,7 +163,7 @@ func getTestingValidator(t *testing.T, app *simapp.SimApp, ctx sdk.Context, acco require.NoError(t, err) validator.DelegatorShares = sdk.NewDec(100) - validator.Tokens = sdkmath.NewInt(1000000) + validator.Tokens = sdk.NewInt(1000000) app.StakingKeeper.SetValidator(ctx, validator) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index b389a73cb47f..a97954254826 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -82,7 +82,7 @@ func TestStakingMsgs(t *testing.T) { validator := checkValidator(t, app, sdk.ValAddress(addr1), true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, types.Bonded, validator.Status) - require.True(sdkmath.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) diff --git a/x/staking/bench_test.go b/x/staking/bench_test.go index 0a6faac5a0f5..7705b6d3114f 100644 --- a/x/staking/bench_test.go +++ b/x/staking/bench_test.go @@ -31,7 +31,7 @@ func benchmarkValidateGenesis(b *testing.B, n int) { addr, pubKey := addressL[i], pubKeyL[i] validator := teststaking.NewValidator(b, addr, pubKey) ni := int64(i + 1) - validator.Tokens = sdkmath.NewInt(ni) + validator.Tokens = sdk.NewInt(ni) validator.DelegatorShares = sdk.NewDec(ni) validators = append(validators, validator) } diff --git a/x/staking/client/testutil/grpc.go b/x/staking/client/testutil/grpc.go index 3b0971d61542..26093aa15bc3 100644 --- a/x/staking/client/testutil/grpc.go +++ b/x/staking/client/testutil/grpc.go @@ -272,7 +272,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegation() { ValidatorAddress: val2.ValAddress.String(), Shares: sdk.NewDec(10), }, - Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10)), + Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)), }, }, }, @@ -751,8 +751,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryPool() { &types.QueryPoolResponse{}, &types.QueryPoolResponse{ Pool: types.Pool{ - NotBondedTokens: sdkmath.NewInt(0), - BondedTokens: cli.DefaultTokens.Mul(sdkmath.NewInt(2)), + NotBondedTokens: sdk.NewInt(0), + BondedTokens: cli.DefaultTokens.Mul(sdk.NewInt(2)), }, }, }, diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index ef1965905bf1..879808868eb9 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -74,7 +74,7 @@ func (s *IntegrationTestSuite) SetupSuite() { _, err = s.network.WaitForHeight(1) s.Require().NoError(err) - unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5)) + unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5)) // unbonding the amount out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount) s.Require().NoError(err) @@ -116,9 +116,9 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) require.NoError(err) @@ -143,7 +143,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -162,7 +162,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -182,7 +182,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -203,7 +203,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -366,7 +366,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() { ValidatorAddress: val2.ValAddress.String(), Shares: sdk.NewDec(10), }, - Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10)), + Balance: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)), }, }, } @@ -932,7 +932,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryPool() { fmt.Sprintf("--%s=1", flags.FlagHeight), }, fmt.Sprintf(`bonded_tokens: "%s" -not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdkmath.NewInt(2)).String()), +not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), }, { "with json", @@ -940,7 +940,7 @@ not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdkmath.NewInt(2)).String()), fmt.Sprintf("--%s=json", tmcli.OutputFlag), fmt.Sprintf("--%s=1", flags.FlagHeight), }, - fmt.Sprintf(`{"not_bonded_tokens":"0","bonded_tokens":"%s"}`, cli.DefaultTokens.Mul(sdkmath.NewInt(2)).String()), + fmt.Sprintf(`{"not_bonded_tokens":"0","bonded_tokens":"%s"}`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), }, } for _, tc := range testCases { @@ -976,7 +976,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, "with wrong from address"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -986,7 +986,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -997,7 +997,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1008,7 +1008,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1019,7 +1019,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1030,7 +1030,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1044,7 +1044,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1086,9 +1086,9 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) s.Require().NoError(err) @@ -1106,18 +1106,18 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, { "without validator address", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -1125,11 +1125,11 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { "valid transaction of delegate", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1175,47 +1175,47 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, { "with wrong source validator address", []string{ - `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr - val2.ValAddress.String(), // dst-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount + `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr + val2.ValAddress.String(), // dst-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 3, &sdk.TxResponse{}, }, { "with wrong destination validator address", []string{ - val.ValAddress.String(), // dst-validator-addr - `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount + val.ValAddress.String(), // dst-validator-addr + `cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj`, // src-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 31, &sdk.TxResponse{}, }, { "valid transaction of delegate", []string{ - val.ValAddress.String(), // src-validator-addr - val2.ValAddress.String(), // dst-validator-addr - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), // amount + val.ValAddress.String(), // src-validator-addr + val2.ValAddress.String(), // dst-validator-addr + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 300000), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1259,18 +1259,18 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, { "Without validator address", []string{ - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -1278,11 +1278,11 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() { "valid transaction of unbond", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1325,7 +1325,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -1336,7 +1336,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -1344,11 +1344,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Without unbond creation height", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, true, 0, nil, }, @@ -1356,12 +1356,12 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Wrong unbonding creation height", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10)).String(), - sdkmath.NewInt(10000).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), + sdk.NewInt(10000).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, sdkerrors.ErrNotFound.ABCICode(), &sdk.TxResponse{}, }, @@ -1369,11 +1369,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "Invalid unbonding amount (higher than the unbonding amount)", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10000)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10000)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, sdkerrors.ErrInvalidRequest.ABCICode(), &sdk.TxResponse{}, }, @@ -1381,11 +1381,11 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "valid transaction of canceling unbonding delegation", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(5)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, false, 0, &sdk.TxResponse{}, }, @@ -1447,9 +1447,9 @@ func (s *IntegrationTestSuite) TestBlockResults() { val.ClientCtx, val.Address, newAddr, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), ) require.NoError(err) @@ -1459,11 +1459,11 @@ func (s *IntegrationTestSuite) TestBlockResults() { cmd := cli.NewDelegateCmd() _, err = clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(150)).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }) require.NoError(err) @@ -1514,7 +1514,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", cli.FlagEditMoniker, moniker), fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }) require.NoError(err) @@ -1534,7 +1534,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }) require.NoError(err) diff --git a/x/staking/client/testutil/test_helpers.go b/x/staking/client/testutil/test_helpers.go index 7adc43d8e711..3a31ea004f3d 100644 --- a/x/staking/client/testutil/test_helpers.go +++ b/x/staking/client/testutil/test_helpers.go @@ -14,7 +14,7 @@ import ( var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), } // MsgRedelegateExec creates a redelegate message. diff --git a/x/staking/genesis.go b/x/staking/genesis.go index 42a9eef2cc5c..c019359c3526 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -21,8 +21,8 @@ func InitGenesis( ctx sdk.Context, keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, data *types.GenesisState, ) (res []abci.ValidatorUpdate) { - bondedTokens := sdkmath.ZeroInt() - notBondedTokens := sdkmath.ZeroInt() + bondedTokens := sdk.ZeroInt() + notBondedTokens := sdk.ZeroInt() // We need to pretend to be "n blocks before genesis", where "n" is the // validator update delay, so that e.g. slashing periods are correctly diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 579fb2f3de55..df6120b04361 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -23,7 +23,7 @@ import ( func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { _, app, ctx := getBaseSimappWithCustomKeeper(t) - addrDels, _ := generateAddresses(app, ctx, numAddrs, sdkmath.NewInt(10000)) + addrDels, _ := generateAddresses(app, ctx, numAddrs, sdk.NewInt(10000)) return app, ctx, addrDels } @@ -125,8 +125,8 @@ func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { OperatorAddress: sdk.ValAddress("12345678901234567890").String(), ConsensusPubkey: consPub, Jailed: false, - Tokens: sdkmath.NewInt(10), - DelegatorShares: sdkmath.NewInt(10).ToDec(), + Tokens: sdk.NewInt(10), + DelegatorShares: sdk.NewInt(10).ToDec(), Description: types.NewDescription("bloop", "", "", "", ""), } // valid params @@ -170,7 +170,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { validators := make([]types.Validator, size) var err error - bondedPoolAmt := sdkmath.ZeroInt() + bondedPoolAmt := sdk.ZeroInt() for i := range validators { validators[i], err = types.NewValidator(sdk.ValAddress(addrs[i]), PKs[i], types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", "")) diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index 0b2fe5529015..6833ea4c0baf 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -44,7 +44,7 @@ func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, ty // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int) ([]sdk.AccAddress, []sdk.ValAddress) { - addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdkmath.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) return addrDels, addrVals diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index c12596d485c8..097c3b037e95 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -192,7 +192,7 @@ func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64 // GetDelegatorUnbonding returns the total amount a delegator has unbonding. func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int { - unbonding := sdkmath.ZeroInt() + unbonding := sdk.ZeroInt() k.IterateDelegatorUnbondingDelegations(ctx, delegator, func(ubd types.UnbondingDelegation) bool { for _, entry := range ubd.Entries { unbonding = unbonding.Add(entry.Balance) diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index 60ee0ea40c35..345121e4ed60 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -28,11 +28,11 @@ func TestDelegation(t *testing.T) { DelegatorAddress: delegations[0].DelegatorAddress, }) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdkmath.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrDels) //construct the validators - amts := []sdk.Int{sdkmath.NewInt(9), sdkmath.NewInt(8), sdkmath.NewInt(7)} + amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)} var validators [3]types.Validator for i, amt := range amts { validators[i] = teststaking.NewValidator(t, valAddrs[i], PKs[i]) @@ -149,7 +149,7 @@ func TestDelegation(t *testing.T) { func TestUnbondingDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) ubd := types.NewUnbondingDelegation( @@ -157,7 +157,7 @@ func TestUnbondingDelegation(t *testing.T) { valAddrs[0], 0, time.Unix(0, 0).UTC(), - sdkmath.NewInt(5), + sdk.NewInt(5), ) // set and retrieve a record @@ -167,7 +167,7 @@ func TestUnbondingDelegation(t *testing.T) { require.Equal(t, ubd, resUnbond) // modify a records, save, and retrieve - expUnbond := sdkmath.NewInt(21) + expUnbond := sdk.NewInt(21) ubd.Entries[0].Balance = expUnbond app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) @@ -199,7 +199,7 @@ func TestUnbondingDelegation(t *testing.T) { func TestUnbondDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -238,7 +238,7 @@ func TestUnbondDelegation(t *testing.T) { func TestUnbondingDelegationsMaxEntries(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -256,7 +256,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { require.Equal(t, startTokens, issuedShares.RoundInt()) validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true) - require.True(sdkmath.IntEq(t, startTokens, validator.BondedTokens())) + require.True(sdk.IntEq(t, startTokens, validator.BondedTokens())) require.True(t, validator.IsBonded()) delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) @@ -277,8 +277,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) - require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) + require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) + require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) oldBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -290,8 +290,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, newBonded, oldBonded)) - require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded)) + require.True(sdk.IntEq(t, newBonded, oldBonded)) + require.True(sdk.IntEq(t, newNotBonded, oldNotBonded)) // mature unbonding delegations ctx = ctx.WithBlockTime(completionTime) @@ -300,8 +300,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, newBonded, oldBonded)) - require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) + require.True(sdk.IntEq(t, newBonded, oldBonded)) + require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -311,8 +311,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, newBonded, oldBonded.SubRaw(1))) - require.True(sdkmath.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) + require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(1))) + require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) } //// test undelegating self delegation from a validator pushing it below MinSelfDelegation @@ -320,7 +320,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(10000)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) @@ -382,7 +382,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) //create a validator with a self-delegation @@ -458,7 +458,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { ubd, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[1], addrVals[0]) require.True(t, found) require.Len(t, ubd.Entries, 1) - require.True(t, ubd.Entries[0].Balance.Equal(sdkmath.NewInt(6))) + require.True(t, ubd.Entries[0].Balance.Equal(sdk.NewInt(6))) assert.Equal(t, blockHeight2, ubd.Entries[0].CreationHeight) assert.True(t, blockTime2.Add(params.UnbondingTime).Equal(ubd.Entries[0].CompletionTime)) } @@ -468,7 +468,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // add bonded tokens to pool for delegations @@ -549,7 +549,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // add bonded tokens to pool for delegations @@ -620,11 +620,11 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { func TestGetRedelegationsFromSrcValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(0, 0), sdkmath.NewInt(5), + time.Unix(0, 0), sdk.NewInt(5), sdk.NewDec(5)) // set and retrieve a record @@ -647,11 +647,11 @@ func TestGetRedelegationsFromSrcValidator(t *testing.T) { func TestRedelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(0, 0).UTC(), sdkmath.NewInt(5), + time.Unix(0, 0).UTC(), sdk.NewInt(5), sdk.NewDec(5)) // test shouldn't have and redelegations @@ -710,7 +710,7 @@ func TestRedelegation(t *testing.T) { func TestRedelegateToSameValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) @@ -739,7 +739,7 @@ func TestRedelegateToSameValidator(t *testing.T) { func TestRedelegationMaxEntries(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) @@ -795,7 +795,7 @@ func TestRedelegationMaxEntries(t *testing.T) { func TestRedelegateSelfDelegation(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) @@ -851,7 +851,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { func TestRedelegateFromUnbondingValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) @@ -933,7 +933,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { func TestRedelegateFromUnbondedValidator(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index f4c98e57b3af..437269956936 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -26,7 +26,7 @@ func IsValSetSorted(data []types.Validator, powerReduction sdk.Int) bool { func TestHistoricalInfo(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) validators := make([]types.Validator, len(addrVals)) @@ -53,7 +53,7 @@ func TestHistoricalInfo(t *testing.T) { func TestTrackHistoricalInfo(t *testing.T) { _, app, ctx := createTestInput(t) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) // set historical entries in params to 5 @@ -139,7 +139,7 @@ func TestGetAllHistoricalInfo(t *testing.T) { require.Len(t, infos, 1) app.StakingKeeper.DeleteHistoricalInfo(ctx, infos[0].Header.Height) - addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdkmath.NewInt(0)) + addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) valSet := []types.Validator{ diff --git a/x/staking/keeper/invariants.go b/x/staking/keeper/invariants.go index 55cfda81f5b7..ed88ec62518e 100644 --- a/x/staking/keeper/invariants.go +++ b/x/staking/keeper/invariants.go @@ -46,8 +46,8 @@ func AllInvariants(k Keeper) sdk.Invariant { // reflects the tokens actively bonded and not bonded func ModuleAccountInvariants(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - bonded := sdkmath.ZeroInt() - notBonded := sdkmath.ZeroInt() + bonded := sdk.ZeroInt() + notBonded := sdk.ZeroInt() bondedPool := k.GetBondedPool(ctx) notBondedPool := k.GetNotBondedPool(ctx) bondDenom := k.BondDenom(ctx) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 49854b741d94..5dde8f1bb92a 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -3,9 +3,8 @@ package keeper import ( "fmt" - "github.com/tendermint/tendermint/libs/log" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -80,7 +79,7 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) sdk.Int { bz := store.Get(types.LastTotalPowerKey) if bz == nil { - return sdkmath.ZeroInt() + return sdk.ZeroInt() } ip := sdk.IntProto{} diff --git a/x/staking/keeper/msg_server_test.go b/x/staking/keeper/msg_server_test.go index 46b28c414e17..44538be4d4ae 100644 --- a/x/staking/keeper/msg_server_test.go +++ b/x/staking/keeper/msg_server_test.go @@ -4,14 +4,13 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestCancelUnbondingDelegation(t *testing.T) { @@ -32,7 +31,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { require.Equal(t, sdk.NewInt64Coin(bondDenom, startTokens.Int64()), moduleBalance) // accounts - delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdkmath.NewInt(10000)) + delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000)) validators := app.StakingKeeper.GetValidators(ctx, 10) require.Equal(t, len(validators), 1) @@ -65,7 +64,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { req: types.MsgCancelUnbondingDelegation{ DelegatorAddress: resUnbond.DelegatorAddress, ValidatorAddress: resUnbond.ValidatorAddress, - Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdkmath.NewInt(4)), + Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(4)), CreationHeight: 0, }, }, @@ -75,7 +74,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { req: types.MsgCancelUnbondingDelegation{ DelegatorAddress: resUnbond.DelegatorAddress, ValidatorAddress: resUnbond.ValidatorAddress, - Amount: sdk.NewCoin("dump_coin", sdkmath.NewInt(4)), + Amount: sdk.NewCoin("dump_coin", sdk.NewInt(4)), CreationHeight: 0, }, }, diff --git a/x/staking/keeper/power_reduction_test.go b/x/staking/keeper/power_reduction_test.go index 9918124c42b6..e18230d854b2 100644 --- a/x/staking/keeper/power_reduction_test.go +++ b/x/staking/keeper/power_reduction_test.go @@ -5,11 +5,11 @@ import ( ) func (suite *KeeperTestSuite) TestTokensToConsensusPower() { - suite.Require().Equal(int64(0), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction.Sub(sdkmath.NewInt(1)))) + suite.Require().Equal(int64(0), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction.Sub(sdk.NewInt(1)))) suite.Require().Equal(int64(1), suite.app.StakingKeeper.TokensToConsensusPower(suite.ctx, sdk.DefaultPowerReduction)) } func (suite *KeeperTestSuite) TestTokensFromConsensusPower() { - suite.Require().Equal(sdkmath.NewInt(0), suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 0)) + suite.Require().Equal(sdk.NewInt(0), suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 0)) suite.Require().Equal(sdk.DefaultPowerReduction, suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 1)) } diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index b7343ff4b06d..f50e95a1833e 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -19,12 +19,12 @@ import ( func TestNewQuerier(t *testing.T) { cdc, app, ctx := createTestInput(t) - addrs := simapp.AddTestAddrs(app, ctx, 500, sdkmath.NewInt(10000)) + addrs := simapp.AddTestAddrs(app, ctx, 500, sdk.NewInt(10000)) _, addrAcc2 := addrs[0], addrs[1] addrVal1, _ := sdk.ValAddress(addrs[0]), sdk.ValAddress(addrs[1]) // Create Validators - amts := []sdk.Int{sdkmath.NewInt(9), sdkmath.NewInt(8)} + amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8)} var validators [2]types.Validator for i, amt := range amts { validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i]) @@ -143,7 +143,7 @@ func TestQueryValidators(t *testing.T) { addrs := simapp.AddTestAddrs(app, ctx, 500, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) // Create Validators - amts := []sdk.Int{sdkmath.NewInt(8), sdkmath.NewInt(7)} + amts := []sdk.Int{sdk.NewInt(8), sdk.NewInt(7)} status := []types.BondStatus{types.Unbonded, types.Unbonding} var validators [2]types.Validator for i, amt := range amts { diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index c89f02dc0b76..279af3a85a35 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -45,7 +45,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh "WARNING: ignored attempt to slash a nonexistent validator; we recommend you investigate immediately", "validator", consAddr.String(), ) - return sdkmath.NewInt(0) + return sdk.NewInt(0) } // should not be slashing an unbonded validator @@ -103,8 +103,8 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh } // cannot decrease balance below zero - tokensToBurn := sdkmath.MinInt(remainingSlashAmount, validator.Tokens) - tokensToBurn = sdkmath.MaxInt(tokensToBurn, sdkmath.ZeroInt()) // defensive. + tokensToBurn := sdk.MinInt(remainingSlashAmount, validator.Tokens) + tokensToBurn = sdk.MaxInt(tokensToBurn, sdk.ZeroInt()) // defensive. // we need to calculate the *effective* slash fraction for distribution if validator.Tokens.IsPositive() { @@ -167,8 +167,8 @@ func (k Keeper) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) { func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation types.UnbondingDelegation, infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdkmath.ZeroInt() - burnedAmount := sdkmath.ZeroInt() + totalSlashAmount = sdk.ZeroInt() + burnedAmount := sdk.ZeroInt() // perform slashing on all entries within the unbonding delegation for i, entry := range unbondingDelegation.Entries { @@ -191,7 +191,7 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty // Possible since the unbonding delegation may already // have been slashed, and slash amounts are calculated // according to stake held at time of infraction - unbondingSlashAmount := sdkmath.MinInt(slashAmount, entry.Balance) + unbondingSlashAmount := sdk.MinInt(slashAmount, entry.Balance) // Update unbonding delegation if necessary if unbondingSlashAmount.IsZero() { @@ -220,8 +220,8 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, redelegation types.Redelegation, infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdkmath.ZeroInt() - bondedBurnedAmount, notBondedBurnedAmount := sdkmath.ZeroInt(), sdkmath.ZeroInt() + totalSlashAmount = sdk.ZeroInt() + bondedBurnedAmount, notBondedBurnedAmount := sdk.ZeroInt(), sdk.ZeroInt() // perform slashing on all entries within the redelegation for _, entry := range redelegation.Entries { diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 68bb0af91623..014173d9d075 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -81,19 +81,19 @@ func TestSlashUnbondingDelegation(t *testing.T) { // set an unbonding delegation with expiration timestamp (beyond which the // unbonding delegation shouldn't be slashed) ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 0, - time.Unix(5, 0), sdkmath.NewInt(10)) + time.Unix(5, 0), sdk.NewInt(10)) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) // unbonding started prior to the infraction height, stakw didn't contribute slashAmount := app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 1, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) + require.True(t, slashAmount.Equal(sdk.NewInt(0))) // after the expiration time, no longer eligible for slashing ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) + require.True(t, slashAmount.Equal(sdk.NewInt(0))) // test valid slash, before expiration timestamp and to which stake contributed notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx) @@ -101,19 +101,19 @@ func TestSlashUnbondingDelegation(t *testing.T) { ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(0, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(5))) + require.True(t, slashAmount.Equal(sdk.NewInt(5))) ubd, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0]) require.True(t, found) require.Len(t, ubd.Entries, 1) // initial balance unchanged - require.Equal(t, sdkmath.NewInt(10), ubd.Entries[0].InitialBalance) + require.Equal(t, sdk.NewInt(10), ubd.Entries[0].InitialBalance) // balance decreased - require.Equal(t, sdkmath.NewInt(5), ubd.Entries[0].Balance) + require.Equal(t, sdk.NewInt(5), ubd.Entries[0].Balance) newUnbondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) diffTokens := oldUnbondedPoolBalances.Sub(newUnbondedPoolBalances...) - require.True(t, diffTokens.AmountOf(app.StakingKeeper.BondDenom(ctx)).Equal(sdkmath.NewInt(5))) + require.True(t, diffTokens.AmountOf(app.StakingKeeper.BondDenom(ctx)).Equal(sdk.NewInt(5))) } // tests slashRedelegation @@ -132,7 +132,7 @@ func TestSlashRedelegation(t *testing.T) { // set a redelegation with an expiration timestamp beyond which the // redelegation shouldn't be slashed rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0, - time.Unix(5, 0), sdkmath.NewInt(10), sdk.NewDec(10)) + time.Unix(5, 0), sdk.NewInt(10), sdk.NewDec(10)) app.StakingKeeper.SetRedelegation(ctx, rd) @@ -144,7 +144,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found := app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount := app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 1, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) + require.True(t, slashAmount.Equal(sdk.NewInt(0))) // after the expiration time, no longer eligible for slashing ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) @@ -152,7 +152,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount = app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 0, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(0))) + require.True(t, slashAmount.Equal(sdk.NewInt(0))) balances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -162,7 +162,7 @@ func TestSlashRedelegation(t *testing.T) { validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) slashAmount = app.StakingKeeper.SlashRedelegation(ctx, validator, rd, 0, fraction) - require.True(t, slashAmount.Equal(sdkmath.NewInt(5))) + require.True(t, slashAmount.Equal(sdk.NewInt(5))) rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) require.True(t, found) require.Len(t, rd.Entries, 1) @@ -171,7 +171,7 @@ func TestSlashRedelegation(t *testing.T) { applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1) // initialbalance unchanged - require.Equal(t, sdkmath.NewInt(10), rd.Entries[0].InitialBalance) + require.Equal(t, sdk.NewInt(10), rd.Entries[0].InitialBalance) // shares decreased del, found = app.StakingKeeper.GetDelegation(ctx, addrDels[0], addrVals[1]) @@ -312,7 +312,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance decreased again - require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -338,7 +338,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance unchanged - require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -364,7 +364,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { require.Len(t, ubd.Entries, 1) // balance unchanged - require.Equal(t, sdkmath.NewInt(0), ubd.Entries[0].Balance) + require.Equal(t, sdk.NewInt(0), ubd.Entries[0].Balance) // just 1 bonded token burned again since that's all the validator now has newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) @@ -423,10 +423,10 @@ func TestSlashWithRedelegation(t *testing.T) { // burn bonded tokens from only from delegations bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -455,14 +455,14 @@ func TestSlashWithRedelegation(t *testing.T) { // seven bonded tokens burned bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) - require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -490,9 +490,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -520,9 +520,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded, bondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded, bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) // read updating redelegation rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -590,10 +590,10 @@ func TestSlashBoth(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) + require.True(sdk.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdkmath.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) + require.True(sdk.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) // read updating redelegation rdA, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -611,10 +611,10 @@ func TestSlashAmount(t *testing.T) { consAddr := sdk.ConsAddress(PKs[0].Address()) fraction := sdk.NewDecWithPrec(5, 1) burnedCoins := app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction) - require.True(t, burnedCoins.GT(sdkmath.ZeroInt())) + require.True(t, burnedCoins.GT(sdk.ZeroInt())) // test the case where the validator was not found, which should return no coins _, addrVals := generateAddresses(app, ctx, 100) noBurned := app.StakingKeeper.Slash(ctx, sdk.ConsAddress(addrVals[0]), ctx.BlockHeight(), 10, fraction) - require.True(t, sdkmath.NewInt(0).Equal(noBurned)) + require.True(t, sdk.NewInt(0).Equal(noBurned)) } diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index ca87967726a6..7392936f5421 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -113,8 +113,8 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab params := k.GetParams(ctx) maxValidators := params.MaxValidators powerReduction := k.PowerReduction(ctx) - totalPower := sdkmath.ZeroInt() - amtFromBondedToNotBonded, amtFromNotBondedToBonded := sdkmath.ZeroInt(), sdkmath.ZeroInt() + totalPower := sdk.ZeroInt() + amtFromBondedToNotBonded, amtFromNotBondedToBonded := sdk.ZeroInt(), sdk.ZeroInt() // Retrieve the last validator set. // The persistent set is updated later in this function. @@ -183,7 +183,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab delete(last, valAddrStr) count++ - totalPower = totalPower.Add(sdkmath.NewInt(newPower)) + totalPower = totalPower.Add(sdk.NewInt(newPower)) } noLongerBonded, err := sortNoLongerBonded(last) diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index a16a811d1d6c..c4109a9f3ddf 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -258,7 +258,7 @@ func TestValidatorBasics(t *testing.T) { for i, power := range powers { validators[i] = teststaking.NewValidator(t, addrVals[i], PKs[i]) validators[i].Status = types.Unbonded - validators[i].Tokens = sdkmath.ZeroInt() + validators[i].Tokens = sdk.ZeroInt() tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power) validators[i], _ = validators[i].AddTokensFromDel(tokens) @@ -295,7 +295,7 @@ func TestValidatorBasics(t *testing.T) { require.Equal(t, 1, len(resVals)) assert.True(ValEq(t, validators[0], resVals[0])) assert.Equal(t, types.Bonded, validators[0].Status) - assert.True(sdkmath.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) + assert.True(sdk.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) // modify a records, save, and retrieve validators[0].Status = types.Bonded @@ -340,7 +340,7 @@ func TestValidatorBasics(t *testing.T) { "attempting to remove a validator which still contains tokens", func() { app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) }) - validators[1].Tokens = sdkmath.ZeroInt() // ...remove all tokens + validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens app.StakingKeeper.SetValidator(ctx, validators[1]) // ...set the validator app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) // Now it can be removed. _, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) @@ -353,7 +353,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { // initialize some validators into the state amts := []sdk.Int{ - sdkmath.NewIntFromUint64(0), + sdk.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), @@ -371,11 +371,11 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { // first make sure everything made it in to the gotValidator group resValidators := app.StakingKeeper.GetBondedValidatorsByPower(ctx) assert.Equal(t, n, len(resValidators)) - assert.Equal(t, sdkmath.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdkmath.NewInt(100).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[2].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdkmath.NewInt(1).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[3].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdkmath.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(100).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[2].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(1).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[3].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators) assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[1].OperatorAddress, resValidators[2].OperatorAddress, "%v", resValidators) @@ -383,14 +383,14 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.Equal(t, validators[0].OperatorAddress, resValidators[4].OperatorAddress, "%v", resValidators) // test a basic increase in voting power - validators[3].Tokens = sdkmath.NewInt(500).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdk.NewInt(500).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) assert.True(ValEq(t, validators[3], resValidators[0])) // test a decrease in voting power - validators[3].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) @@ -398,7 +398,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.True(ValEq(t, validators[4], resValidators[1])) // test equal voting power, different age - validators[3].Tokens = sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)) ctx = ctx.WithBlockHeight(10) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) @@ -415,8 +415,8 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { assert.True(ValEq(t, validators[4], resValidators[1])) // change in voting power of both validators, both still in v-set, no age change - validators[3].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) - validators[4].Tokens = sdkmath.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[3].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) + validators[4].Tokens = sdk.NewInt(300).Mul(app.StakingKeeper.PowerReduction(ctx)) keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) resValidators = app.StakingKeeper.GetBondedValidatorsByPower(ctx) require.Equal(t, len(resValidators), n) @@ -446,7 +446,7 @@ func TestGetValidatorSortingMixed(t *testing.T) { // initialize some validators into the state amts := []sdk.Int{ - sdkmath.NewIntFromUint64(0), + sdk.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), @@ -481,8 +481,8 @@ func TestGetValidatorSortingMixed(t *testing.T) { resValidators := app.StakingKeeper.GetBondedValidatorsByPower(ctx) // The validators returned should match the max validators assert.Equal(t, 2, len(resValidators)) - assert.Equal(t, sdkmath.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) - assert.Equal(t, sdkmath.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(400).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[0].BondedTokens(), "%v", resValidators) + assert.Equal(t, sdk.NewInt(200).Mul(app.StakingKeeper.PowerReduction(ctx)), resValidators[1].BondedTokens(), "%v", resValidators) assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators) assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators) } @@ -585,10 +585,10 @@ func TestGetValidatorsEdgeCases(t *testing.T) { // validator 3 does not get spot back app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, validators[3]) - validators[3], _ = validators[3].AddTokensFromDel(sdkmath.NewInt(200)) + validators[3], _ = validators[3].AddTokensFromDel(sdk.NewInt(200)) notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) - require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdkmath.NewInt(200))))) + require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200))))) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true) @@ -943,7 +943,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { // zero power valPubKey := PKs[len(validators)+1] valAddr := sdk.ValAddress(valPubKey.Address().Bytes()) - amt := sdkmath.NewInt(100) + amt := sdk.NewInt(100) validator := teststaking.NewValidator(t, valAddr, valPubKey) validator, _ = validator.AddTokensFromDel(amt) diff --git a/x/staking/module.go b/x/staking/module.go index 39665347c994..92aab0885d44 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -71,11 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the staking module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/staking` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/staking/simulation/genesis.go b/x/staking/simulation/genesis.go index 38c02069286e..f8737f7f7e0a 100644 --- a/x/staking/simulation/genesis.go +++ b/x/staking/simulation/genesis.go @@ -89,7 +89,7 @@ func RandomizedGenState(simState *module.SimulationState) { if err != nil { panic(err) } - validator.Tokens = sdkmath.NewInt(simState.InitialStake) + validator.Tokens = sdk.NewInt(simState.InitialStake) validator.DelegatorShares = sdk.NewDec(simState.InitialStake) validator.Commission = commission diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index b501a1ec2e22..2c04abe875a8 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -6,13 +6,12 @@ import ( "testing" "time" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -323,7 +322,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) diff --git a/x/staking/types/delegation_test.go b/x/staking/types/delegation_test.go index 813d5d068b43..7ca5e8132eb4 100644 --- a/x/staking/types/delegation_test.go +++ b/x/staking/types/delegation_test.go @@ -33,7 +33,7 @@ func TestDelegationString(t *testing.T) { func TestUnbondingDelegationEqual(t *testing.T) { ubd1 := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, - time.Unix(0, 0), sdkmath.NewInt(0)) + time.Unix(0, 0), sdk.NewInt(0)) ubd2 := ubd1 ok := ubd1.String() == ubd2.String() @@ -48,17 +48,17 @@ func TestUnbondingDelegationEqual(t *testing.T) { func TestUnbondingDelegationString(t *testing.T) { ubd := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, - time.Unix(0, 0), sdkmath.NewInt(0)) + time.Unix(0, 0), sdk.NewInt(0)) require.NotEmpty(t, ubd.String()) } func TestRedelegationEqual(t *testing.T) { r1 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdkmath.NewInt(0), + time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(0)) r2 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdkmath.NewInt(0), + time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(0)) ok := r1.String() == r2.String() @@ -73,7 +73,7 @@ func TestRedelegationEqual(t *testing.T) { func TestRedelegationString(t *testing.T) { r := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, - time.Unix(0, 0), sdkmath.NewInt(0), + time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(10)) require.NotEmpty(t, r.String()) @@ -82,9 +82,9 @@ func TestRedelegationString(t *testing.T) { func TestDelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() dr1 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), - sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5))) + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) dr2 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), - sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5))) + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) drs := types.DelegationResponses{dr1, dr2} bz1, err := json.Marshal(dr1) @@ -111,8 +111,8 @@ func TestDelegationResponses(t *testing.T) { func TestRedelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() entries := []types.RedelegationEntryResponse{ - types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdkmath.NewInt(5), sdkmath.NewInt(5)), - types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdkmath.NewInt(5), sdkmath.NewInt(5)), + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), } rdr1 := types.NewRedelegationResponse(sdk.AccAddress(valAddr1), valAddr2, valAddr3, entries) rdr2 := types.NewRedelegationResponse(sdk.AccAddress(valAddr2), valAddr1, valAddr3, entries) diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 02026d2ccf80..35667f949da5 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -26,7 +26,7 @@ var ( func TestGetValidatorPowerRank(t *testing.T) { valAddr1 := sdk.ValAddress(keysAddr1) val1 := newValidator(t, valAddr1, keysPK1) - val1.Tokens = sdkmath.ZeroInt() + val1.Tokens = sdk.ZeroInt() val2, val3, val4 := val1, val1, val1 val2.Tokens = sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction) val3.Tokens = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 8fd2ca25741a..f1ba552d9115 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -72,8 +72,8 @@ func TestMsgCreateValidator(t *testing.T) { {"empty pubkey", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, emptyPubkey, coinPos, false}, {"empty bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, coinZero, false}, {"nil bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, sdk.Coin{}, false}, - {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdkmath.ZeroInt(), valAddr1, pk1, coinPos, false}, - {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdkmath.NewInt(-1), valAddr1, pk1, coinPos, false}, + {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdk.ZeroInt(), valAddr1, pk1, coinPos, false}, + {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdk.NewInt(-1), valAddr1, pk1, coinPos, false}, {"delegation less than min self delegation", "a", "b", "c", "d", "e", commission1, coinPos.Amount.Add(sdk.OneInt()), valAddr1, pk1, coinPos, false}, } diff --git a/x/staking/types/params.go b/x/staking/types/params.go index ca84b7fb8021..cb9def63e00e 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -211,7 +211,7 @@ func ValidatePowerReduction(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.LT(sdkmath.NewInt(1)) { + if v.LT(sdk.NewInt(1)) { return fmt.Errorf("power reduction cannot be lower than 1") } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 23ae1a3ec1b0..79bd2a4f55b1 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -50,7 +50,7 @@ func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, descriptio ConsensusPubkey: pkAny, Jailed: false, Status: Unbonded, - Tokens: sdkmath.ZeroInt(), + Tokens: sdk.ZeroInt(), DelegatorShares: sdk.ZeroDec(), Description: description, UnbondingHeight: int64(0), @@ -351,7 +351,7 @@ func (v Validator) BondedTokens() sdk.Int { return v.Tokens } - return sdkmath.ZeroInt() + return sdk.ZeroInt() } // ConsensusPower gets the consensus-engine power. Aa reduction of 10^6 from @@ -423,7 +423,7 @@ func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) { if remainingShares.IsZero() { // last delegation share gets any trimmings issuedTokens = v.Tokens - v.Tokens = sdkmath.ZeroInt() + v.Tokens = sdk.ZeroInt() } else { // leave excess tokens in the validator // however fully use all the delegator shares diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 1929c1d53f77..8601fbeec723 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -78,7 +78,7 @@ func TestShareTokens(t *testing.T) { validator := mkValidator(100, sdk.NewDec(100)) assert.True(sdk.DecEq(t, sdk.NewDec(50), validator.TokensFromShares(sdk.NewDec(50)))) - validator.Tokens = sdkmath.NewInt(50) + validator.Tokens = sdk.NewInt(50) assert.True(sdk.DecEq(t, sdk.NewDec(25), validator.TokensFromShares(sdk.NewDec(50)))) assert.True(sdk.DecEq(t, sdk.NewDec(5), validator.TokensFromShares(sdk.NewDec(10)))) } @@ -87,36 +87,36 @@ func TestRemoveTokens(t *testing.T) { validator := mkValidator(100, sdk.NewDec(100)) // remove tokens and test check everything - validator = validator.RemoveTokens(sdkmath.NewInt(10)) + validator = validator.RemoveTokens(sdk.NewInt(10)) require.Equal(t, int64(90), validator.Tokens.Int64()) // update validator to from bonded -> unbonded validator = validator.UpdateStatus(types.Unbonded) require.Equal(t, types.Unbonded, validator.Status) - validator = validator.RemoveTokens(sdkmath.NewInt(10)) - require.Panics(t, func() { validator.RemoveTokens(sdkmath.NewInt(-1)) }) - require.Panics(t, func() { validator.RemoveTokens(sdkmath.NewInt(100)) }) + validator = validator.RemoveTokens(sdk.NewInt(10)) + require.Panics(t, func() { validator.RemoveTokens(sdk.NewInt(-1)) }) + require.Panics(t, func() { validator.RemoveTokens(sdk.NewInt(100)) }) } func TestAddTokensValidatorBonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Bonded) - validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.BondedTokens())) + assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.BondedTokens())) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } func TestAddTokensValidatorUnbonding(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Unbonding) - validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonding, validator.Status) - assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) + assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -124,11 +124,11 @@ func TestAddTokensValidatorUnbonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Unbonded) - validator, delShares := validator.AddTokensFromDel(sdkmath.NewInt(10)) + validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonded, validator.Status) - assert.True(sdkmath.IntEq(t, sdkmath.NewInt(10), validator.Tokens)) + assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -138,7 +138,7 @@ func TestRemoveDelShares(t *testing.T) { OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, Status: types.Bonded, - Tokens: sdkmath.NewInt(100), + Tokens: sdk.NewInt(100), DelegatorShares: sdk.NewDec(100), } @@ -152,26 +152,26 @@ func TestRemoveDelShares(t *testing.T) { validator := mkValidator(5102, sdk.NewDec(115)) _, tokens := validator.RemoveDelShares(sdk.NewDec(29)) - require.True(sdkmath.IntEq(t, sdkmath.NewInt(1286), tokens)) + require.True(sdk.IntEq(t, sdk.NewInt(1286), tokens)) } func TestAddTokensFromDel(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator, shares := validator.AddTokensFromDel(sdkmath.NewInt(6)) + validator, shares := validator.AddTokensFromDel(sdk.NewInt(6)) require.True(sdk.DecEq(t, sdk.NewDec(6), shares)) require.True(sdk.DecEq(t, sdk.NewDec(6), validator.DelegatorShares)) - require.True(sdkmath.IntEq(t, sdkmath.NewInt(6), validator.Tokens)) + require.True(sdk.IntEq(t, sdk.NewInt(6), validator.Tokens)) - validator, shares = validator.AddTokensFromDel(sdkmath.NewInt(3)) + validator, shares = validator.AddTokensFromDel(sdk.NewInt(3)) require.True(sdk.DecEq(t, sdk.NewDec(3), shares)) require.True(sdk.DecEq(t, sdk.NewDec(9), validator.DelegatorShares)) - require.True(sdkmath.IntEq(t, sdkmath.NewInt(9), validator.Tokens)) + require.True(sdk.IntEq(t, sdk.NewInt(9), validator.Tokens)) } func TestUpdateStatus(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator, _ = validator.AddTokensFromDel(sdkmath.NewInt(100)) + validator, _ = validator.AddTokensFromDel(sdk.NewInt(100)) require.Equal(t, types.Unbonded, validator.Status) require.Equal(t, int64(100), validator.Tokens.Int64()) @@ -191,7 +191,7 @@ func TestUpdateStatus(t *testing.T) { func TestPossibleOverflow(t *testing.T) { delShares := sdk.NewDec(391432570689183511).Quo(sdk.NewDec(40113011844664)) validator := mkValidator(2159, delShares) - newValidator, _ := validator.AddTokensFromDel(sdkmath.NewInt(71)) + newValidator, _ := validator.AddTokensFromDel(sdk.NewInt(71)) require.False(t, newValidator.DelegatorShares.IsNegative()) require.False(t, newValidator.Tokens.IsNegative()) @@ -280,11 +280,11 @@ func TestValidatorsSortTendermint(t *testing.T) { pk2 := ed25519.GenPrivKey().PubKey() vals[i] = newValidator(t, sdk.ValAddress(pk2.Address()), pk) vals[i].Status = types.Bonded - vals[i].Tokens = sdkmath.NewInt(rand.Int63()) + vals[i].Tokens = sdk.NewInt(rand.Int63()) } // create some validators with the same power for i := 0; i < 10; i++ { - vals[i].Tokens = sdkmath.NewInt(1000000) + vals[i].Tokens = sdk.NewInt(1000000) } valz := types.Validators(vals) @@ -312,7 +312,7 @@ func TestValidatorToTm(t *testing.T) { pk := ed25519.GenPrivKey().PubKey() val := newValidator(t, sdk.ValAddress(pk.Address()), pk) val.Status = types.Bonded - val.Tokens = sdkmath.NewInt(rand.Int63()) + val.Tokens = sdk.NewInt(rand.Int63()) vals[i] = val tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) require.NoError(t, err) @@ -339,7 +339,7 @@ func mkValidator(tokens int64, shares sdk.Dec) types.Validator { OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, Status: types.Bonded, - Tokens: sdkmath.NewInt(tokens), + Tokens: sdk.NewInt(tokens), DelegatorShares: shares, } } diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index dd9f4cec3952..a91b0b748d21 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -42,7 +42,7 @@ func (s *KeeperTestSuite) SetupTest() { Height: 10, }) s.msgSrvr = keeper.NewMsgServerImpl(s.app.UpgradeKeeper) - s.addrs = simapp.AddTestAddrsIncremental(app, s.ctx, 1, sdkmath.NewInt(30000000)) + s.addrs = simapp.AddTestAddrsIncremental(app, s.ctx, 1, sdk.NewInt(30000000)) } func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() { diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 045d23370586..526e7c791cdc 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -41,11 +40,6 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterLegacyAminoCodec(cdc) } -// RegisterRESTRoutes registers the REST routes for the upgrade module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/upgrade` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the upgrade module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { From cc17a90121e7b7b804b74255c7f86ac9d7d32819 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:14:37 -0400 Subject: [PATCH 12/22] updates --- simapp/simd/cmd/testnet.go | 3 +-- simapp/state.go | 3 +-- simapp/test_helpers.go | 9 ++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 0254828f89c6..858997d0caf2 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -24,7 +24,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/testutil" @@ -300,7 +299,7 @@ func initTestnetFiles( sdk.NewCoin(sdk.DefaultBondDenom, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdkmath.OneInt(), + sdk.OneInt(), ) if err != nil { return err diff --git a/simapp/state.go b/simapp/state.go index b8d4fd612fc0..f888a45bcd8b 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - sdkmath "github.com/cosmos/cosmos-sdk/math" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -89,7 +88,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty panic(err) } // compute not bonded balance - notBondedTokens := sdkmath.ZeroInt() + notBondedTokens := sdk.ZeroInt() for _, val := range stakingState.Validators { if val.Status != stakingtypes.Unbonded { continue diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index c51db38c6ad4..4fe0c2b4d87f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -25,7 +25,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/simapp/params" @@ -94,7 +93,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } app := NewSimApp(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.EncConfig, options.AppOpts) @@ -136,7 +135,7 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp { acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -173,7 +172,7 @@ func genesisStateWithValSet(t *testing.T, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdkmath.ZeroInt(), + MinSelfDelegation: sdk.ZeroInt(), } validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) @@ -276,7 +275,7 @@ func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState { balances := []banktypes.Balance{ { Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), }, } From 18a7174c83eb26acff952f06e961d5b9c68d7102 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:15:45 -0400 Subject: [PATCH 13/22] updates --- server/rosetta/converter.go | 3 +-- testutil/network/network.go | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/server/rosetta/converter.go b/server/rosetta/converter.go index 841d1407a0ba..6782073aaff6 100644 --- a/server/rosetta/converter.go +++ b/server/rosetta/converter.go @@ -18,7 +18,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors" crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -421,7 +420,7 @@ func (c converter) Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*r value, owned := ownedCoinsMap[coin.Denom] if !owned { amounts[i] = &rosettatypes.Amount{ - Value: sdkmath.NewInt(0).String(), + Value: sdk.NewInt(0).String(), Currency: &rosettatypes.Currency{ Symbol: coin.Denom, }, diff --git a/testutil/network/network.go b/testutil/network/network.go index a695b5d2d964..995eb56889df 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -32,7 +32,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" @@ -402,7 +401,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), - sdkmath.OneInt(), + sdk.OneInt(), ) if err != nil { return nil, err @@ -414,7 +413,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { } memo := fmt.Sprintf("%s@%s:%s", nodeIDs[i], p2pURL.Hostname(), p2pURL.Port()) - fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdkmath.NewInt(0))) + fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdk.NewInt(0))) txBuilder := cfg.TxConfig.NewTxBuilder() err = txBuilder.SetMsgs(createValMsg) if err != nil { From b15d49d7f94272f5e6b8b031a938886138a77f98 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:17:32 -0400 Subject: [PATCH 14/22] updates --- types/math.go | 5 +++++ types/simulation/rand_util.go | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/math.go b/types/math.go index be20e1cfff72..0392b0d1f640 100644 --- a/types/math.go +++ b/types/math.go @@ -15,6 +15,11 @@ type ( Uint = sdkmath.Uint ) +var ( + NewIntFromBigInt = sdkmath.NewIntFromBigInt + OneInt = sdkmath.OneInt +) + func (ip IntProto) String() string { return ip.Int.String() } diff --git a/types/simulation/rand_util.go b/types/simulation/rand_util.go index f359ad165182..f136da396990 100644 --- a/types/simulation/rand_util.go +++ b/types/simulation/rand_util.go @@ -7,7 +7,6 @@ import ( "time" "unsafe" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -42,13 +41,13 @@ func RandStringOfLength(r *rand.Rand, n int) string { // RandPositiveInt get a rand positive sdk.Int func RandPositiveInt(r *rand.Rand, max sdk.Int) (sdk.Int, error) { - if !max.GTE(sdkmath.OneInt()) { + if !max.GTE(sdk.OneInt()) { return sdk.Int{}, errors.New("max too small") } - max = max.Sub(sdkmath.OneInt()) + max = max.Sub(sdk.OneInt()) - return sdkmath.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdkmath.OneInt()), nil + return sdk.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdk.OneInt()), nil } // RandomAmount generates a random amount @@ -65,7 +64,7 @@ func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { randInt = big.NewInt(0).Rand(r, max.BigInt()) // up to max - 1 } - return sdkmath.NewIntFromBigInt(randInt) + return sdk.NewIntFromBigInt(randInt) } // RandomDecAmount generates a random decimal amount From 48839732119d510a601d3ae3c8241bf026c03484 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:24:31 -0400 Subject: [PATCH 15/22] updates --- types/bench_test.go | 11 +- types/coin.go | 8 +- types/coin_benchmark_test.go | 10 +- types/coin_internal_test.go | 4 +- types/coin_test.go | 227 +++++++++++++++++------------------ types/dec_coin.go | 4 +- types/dec_coin_test.go | 43 ++++--- types/decimal.go | 8 +- types/decimal_test.go | 41 +++---- types/denom_internal_test.go | 74 ++++++------ types/events_test.go | 3 +- types/math.go | 10 ++ types/staking.go | 8 +- types/staking_test.go | 5 +- 14 files changed, 222 insertions(+), 234 deletions(-) diff --git a/types/bench_test.go b/types/bench_test.go index 049860968a61..89fd9f19ea02 100644 --- a/types/bench_test.go +++ b/types/bench_test.go @@ -3,8 +3,7 @@ package types_test import ( "testing" - sdkmath "github.com/cosmos/cosmos-sdk/math" - "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) var coinStrs = []string{ @@ -15,11 +14,11 @@ var coinStrs = []string{ } func BenchmarkParseCoin(b *testing.B) { - var blankCoin types.Coin + var blankCoin sdk.Coin b.ReportAllocs() for i := 0; i < b.N; i++ { for _, coinStr := range coinStrs { - coin, err := types.ParseCoinNormalized(coinStr) + coin, err := sdk.ParseCoinNormalized(coinStr) if err != nil { b.Fatal(err) } @@ -45,7 +44,7 @@ func BenchmarkUintMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - u := sdkmath.NewUint(value) + u := sdk.NewUint(value) n, err := u.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) @@ -70,7 +69,7 @@ func BenchmarkIntMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - in := sdkmath.NewInt(value) + in := sdk.NewInt(value) n, err := in.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) diff --git a/types/coin.go b/types/coin.go index 7537720756e4..c0ad2ca0cfb5 100644 --- a/types/coin.go +++ b/types/coin.go @@ -6,8 +6,6 @@ import ( "regexp" "sort" "strings" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) //----------------------------------------------------------------------------- @@ -31,7 +29,7 @@ func NewCoin(denom string, amount Int) Coin { // NewInt64Coin returns a new coin with a denomination and amount. It will panic // if the amount is negative. func NewInt64Coin(denom string, amount int64) Coin { - return NewCoin(denom, sdkmath.NewInt(amount)) + return NewCoin(denom, NewInt(amount)) } // String provides a human-readable representation of a coin @@ -642,14 +640,14 @@ func (coins Coins) AmountOf(denom string) Int { func (coins Coins) AmountOfNoDenomValidation(denom string) Int { switch len(coins) { case 0: - return sdkmath.ZeroInt() + return ZeroInt() case 1: coin := coins[0] if coin.Denom == denom { return coin.Amount } - return sdkmath.ZeroInt() + return ZeroInt() default: // Binary search the amount of coins remaining diff --git a/types/coin_benchmark_test.go b/types/coin_benchmark_test.go index ba0256630041..9730284c9b3d 100644 --- a/types/coin_benchmark_test.go +++ b/types/coin_benchmark_test.go @@ -3,8 +3,6 @@ package types import ( "fmt" "testing" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) func coinName(suffix int) string { @@ -20,10 +18,10 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) { coinsB := Coins(make([]Coin, numCoinsB)) for i := 0; i < numCoinsA; i++ { - coinsA[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) + coinsA[i] = NewCoin(coinName(i), NewInt(int64(i))) } for i := 0; i < numCoinsB; i++ { - coinsB[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) + coinsB[i] = NewCoin(coinName(i), NewInt(int64(i))) } b.ResetTimer() @@ -51,10 +49,10 @@ func BenchmarkCoinsAdditionNoIntersect(b *testing.B) { coinsB := Coins(make([]Coin, numCoinsB)) for i := 0; i < numCoinsA; i++ { - coinsA[i] = NewCoin(coinName(numCoinsB+i), sdkmath.NewInt(int64(i))) + coinsA[i] = NewCoin(coinName(numCoinsB+i), NewInt(int64(i))) } for i := 0; i < numCoinsB; i++ { - coinsB[i] = NewCoin(coinName(i), sdkmath.NewInt(int64(i))) + coinsB[i] = NewCoin(coinName(i), NewInt(int64(i))) } b.ResetTimer() diff --git a/types/coin_internal_test.go b/types/coin_internal_test.go index b20942262153..709683795c37 100644 --- a/types/coin_internal_test.go +++ b/types/coin_internal_test.go @@ -4,8 +4,6 @@ import ( "testing" "github.com/stretchr/testify/suite" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) func TestCoinTestSuite(t *testing.T) { @@ -17,7 +15,7 @@ type coinInternalSuite struct { } func (s *coinInternalSuite) TestIsSorted() { - v := sdkmath.NewInt(1) + v := NewInt(1) cases := []struct { coins Coins expected bool diff --git a/types/coin_test.go b/types/coin_test.go index 06e6e911aa89..83c12143078e 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -28,9 +27,9 @@ func TestCoinTestSuite(t *testing.T) { func (s *coinTestSuite) SetupSuite() { s.T().Parallel() - zero := sdkmath.NewInt(0) - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + zero := sdk.NewInt(0) + one := sdk.OneInt() + two := sdk.NewInt(2) s.ca0, s.ca1, s.ca2 = sdk.Coin{testDenom1, zero}, sdk.Coin{testDenom1, one}, sdk.Coin{testDenom1, two} s.cm0, s.cm1, s.cm2 = sdk.Coin{testDenom2, zero}, sdk.Coin{testDenom2, one}, sdk.Coin{testDenom2, two} } @@ -40,15 +39,15 @@ func (s *coinTestSuite) SetupSuite() { func (s *coinTestSuite) TestCoin() { s.Require().Panics(func() { sdk.NewInt64Coin(testDenom1, -1) }) - s.Require().Panics(func() { sdk.NewCoin(testDenom1, sdkmath.NewInt(-1)) }) - s.Require().Equal(sdkmath.NewInt(10), sdk.NewInt64Coin(strings.ToUpper(testDenom1), 10).Amount) - s.Require().Equal(sdkmath.NewInt(10), sdk.NewCoin(strings.ToUpper(testDenom1), sdkmath.NewInt(10)).Amount) - s.Require().Equal(sdkmath.NewInt(5), sdk.NewInt64Coin(testDenom1, 5).Amount) - s.Require().Equal(sdkmath.NewInt(5), sdk.NewCoin(testDenom1, sdkmath.NewInt(5)).Amount) + s.Require().Panics(func() { sdk.NewCoin(testDenom1, sdk.NewInt(-1)) }) + s.Require().Equal(sdk.NewInt(10), sdk.NewInt64Coin(strings.ToUpper(testDenom1), 10).Amount) + s.Require().Equal(sdk.NewInt(10), sdk.NewCoin(strings.ToUpper(testDenom1), sdk.NewInt(10)).Amount) + s.Require().Equal(sdk.NewInt(5), sdk.NewInt64Coin(testDenom1, 5).Amount) + s.Require().Equal(sdk.NewInt(5), sdk.NewCoin(testDenom1, sdk.NewInt(5)).Amount) } func (s *coinTestSuite) TestCoin_String() { - coin := sdk.NewCoin(testDenom1, sdkmath.NewInt(10)) + coin := sdk.NewCoin(testDenom1, sdk.NewInt(10)) s.Require().Equal(fmt.Sprintf("10%s", testDenom1), coin.String()) } @@ -88,17 +87,17 @@ func (s *coinTestSuite) TestCoinIsValid() { coin sdk.Coin expectPass bool }{ - {sdk.Coin{testDenom1, sdkmath.NewInt(-1)}, false}, - {sdk.Coin{testDenom1, sdkmath.NewInt(0)}, true}, - {sdk.Coin{testDenom1, sdkmath.OneInt()}, true}, - {sdk.Coin{"Atom", sdkmath.OneInt()}, true}, - {sdk.Coin{"ATOM", sdkmath.OneInt()}, true}, - {sdk.Coin{"a", sdkmath.OneInt()}, false}, - {sdk.Coin{loremIpsum, sdkmath.OneInt()}, false}, - {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.OneInt()}, true}, - {sdk.Coin{"atOm", sdkmath.OneInt()}, true}, - {sdk.Coin{"x:y-z.1_2", sdkmath.OneInt()}, true}, - {sdk.Coin{" ", sdkmath.OneInt()}, false}, + {sdk.Coin{testDenom1, sdk.NewInt(-1)}, false}, + {sdk.Coin{testDenom1, sdk.NewInt(0)}, true}, + {sdk.Coin{testDenom1, sdk.OneInt()}, true}, + {sdk.Coin{"Atom", sdk.OneInt()}, true}, + {sdk.Coin{"ATOM", sdk.OneInt()}, true}, + {sdk.Coin{"a", sdk.OneInt()}, false}, + {sdk.Coin{loremIpsum, sdk.OneInt()}, false}, + {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, true}, + {sdk.Coin{"atOm", sdk.OneInt()}, true}, + {sdk.Coin{"x:y-z.1_2", sdk.OneInt()}, true}, + {sdk.Coin{" ", sdk.OneInt()}, false}, } for i, tc := range cases { @@ -117,11 +116,11 @@ func (s *coinTestSuite) TestCustomValidation() { coin sdk.Coin expectPass bool }{ - {sdk.Coin{"🙂", sdkmath.NewInt(1)}, true}, - {sdk.Coin{"🙁", sdkmath.NewInt(1)}, true}, - {sdk.Coin{"🌶", sdkmath.NewInt(1)}, false}, // outside the unicode range listed above - {sdk.Coin{"asdf", sdkmath.NewInt(1)}, false}, - {sdk.Coin{"", sdkmath.NewInt(1)}, false}, + {sdk.Coin{"🙂", sdk.NewInt(1)}, true}, + {sdk.Coin{"🙁", sdk.NewInt(1)}, true}, + {sdk.Coin{"🌶", sdk.NewInt(1)}, false}, // outside the unicode range listed above + {sdk.Coin{"asdf", sdk.NewInt(1)}, false}, + {sdk.Coin{"", sdk.NewInt(1)}, false}, } for i, tc := range cases { @@ -159,8 +158,8 @@ func (s *coinTestSuite) TestAddCoinAmount() { amount sdk.Int expected sdk.Coin }{ - {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 2)}, - {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(0), sdk.NewInt64Coin(testDenom1, 1)}, + {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 2)}, + {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(0), sdk.NewInt64Coin(testDenom1, 1)}, } for i, tc := range cases { res := tc.coin.AddAmount(tc.amount) @@ -208,11 +207,11 @@ func (s *coinTestSuite) TestSubCoinAmount() { expected sdk.Coin shouldPanic bool }{ - {sdk.NewInt64Coin(testDenom1, 2), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 1), false}, - {sdk.NewInt64Coin(testDenom1, 10), sdkmath.NewInt(1), sdk.NewInt64Coin(testDenom1, 9), false}, - {sdk.NewInt64Coin(testDenom1, 5), sdkmath.NewInt(3), sdk.NewInt64Coin(testDenom1, 2), false}, - {sdk.NewInt64Coin(testDenom1, 5), sdkmath.NewInt(0), sdk.NewInt64Coin(testDenom1, 5), false}, - {sdk.NewInt64Coin(testDenom1, 1), sdkmath.NewInt(5), sdk.Coin{}, true}, + {sdk.NewInt64Coin(testDenom1, 2), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 1), false}, + {sdk.NewInt64Coin(testDenom1, 10), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 9), false}, + {sdk.NewInt64Coin(testDenom1, 5), sdk.NewInt(3), sdk.NewInt64Coin(testDenom1, 2), false}, + {sdk.NewInt64Coin(testDenom1, 5), sdk.NewInt(0), sdk.NewInt64Coin(testDenom1, 5), false}, + {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(5), sdk.Coin{}, true}, } for i, tc := range cases { @@ -333,11 +332,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "all greater than zero", input: sdk.Coins{ - {"testa", sdkmath.OneInt()}, - {"testb", sdkmath.NewInt(2)}, - {"testc", sdkmath.NewInt(3)}, - {"testd", sdkmath.NewInt(4)}, - {"teste", sdkmath.NewInt(5)}, + {"testa", sdk.OneInt()}, + {"testb", sdk.NewInt(2)}, + {"testc", sdk.NewInt(3)}, + {"testd", sdk.NewInt(4)}, + {"teste", sdk.NewInt(5)}, }, original: "1testa,2testb,3testc,4testd,5teste", expected: "1testa,2testb,3testc,4testd,5teste", @@ -345,11 +344,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "zero coin in middle", input: sdk.Coins{ - {"testa", sdkmath.OneInt()}, - {"testb", sdkmath.NewInt(2)}, - {"testc", sdkmath.NewInt(0)}, - {"testd", sdkmath.NewInt(4)}, - {"teste", sdkmath.NewInt(5)}, + {"testa", sdk.OneInt()}, + {"testb", sdk.NewInt(2)}, + {"testc", sdk.NewInt(0)}, + {"testd", sdk.NewInt(4)}, + {"teste", sdk.NewInt(5)}, }, original: "1testa,2testb,0testc,4testd,5teste", expected: "1testa,2testb,4testd,5teste", @@ -357,11 +356,11 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "zero coin end (unordered)", input: sdk.Coins{ - {"teste", sdkmath.NewInt(5)}, - {"testc", sdkmath.NewInt(3)}, - {"testa", sdkmath.OneInt()}, - {"testd", sdkmath.NewInt(4)}, - {"testb", sdkmath.NewInt(0)}, + {"teste", sdk.NewInt(5)}, + {"testc", sdk.NewInt(3)}, + {"testa", sdk.OneInt()}, + {"testd", sdk.NewInt(4)}, + {"testb", sdk.NewInt(0)}, }, original: "5teste,3testc,1testa,4testd,0testb", expected: "1testa,3testc,4testd,5teste", @@ -391,15 +390,15 @@ func (s *coinTestSuite) TestCoins_String() { }, { "single coin", - sdk.Coins{{"tree", sdkmath.OneInt()}}, + sdk.Coins{{"tree", sdk.OneInt()}}, "1tree", }, { "multiple coins", sdk.Coins{ - {"tree", sdkmath.OneInt()}, - {"gas", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"tree", sdk.OneInt()}, + {"gas", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, "1tree,1gas,1mineral", }, @@ -539,88 +538,88 @@ func (s *coinTestSuite) TestCoins_Validate() { { "valid lowercase coins", sdk.Coins{ - {"gas", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, - {"tree", sdkmath.OneInt()}, + {"gas", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, + {"tree", sdk.OneInt()}, }, true, }, { "valid uppercase coins", sdk.Coins{ - {"GAS", sdkmath.OneInt()}, - {"MINERAL", sdkmath.OneInt()}, - {"TREE", sdkmath.OneInt()}, + {"GAS", sdk.OneInt()}, + {"MINERAL", sdk.OneInt()}, + {"TREE", sdk.OneInt()}, }, true, }, { "valid uppercase coin", sdk.Coins{ - {"ATOM", sdkmath.OneInt()}, + {"ATOM", sdk.OneInt()}, }, true, }, { "valid lower and uppercase coins (1)", sdk.Coins{ - {"GAS", sdkmath.OneInt()}, - {"gAs", sdkmath.OneInt()}, + {"GAS", sdk.OneInt()}, + {"gAs", sdk.OneInt()}, }, true, }, { "valid lower and uppercase coins (2)", sdk.Coins{ - {"ATOM", sdkmath.OneInt()}, - {"Atom", sdkmath.OneInt()}, - {"atom", sdkmath.OneInt()}, + {"ATOM", sdk.OneInt()}, + {"Atom", sdk.OneInt()}, + {"atom", sdk.OneInt()}, }, true, }, { "mixed case (1)", sdk.Coins{ - {"MineraL", sdkmath.OneInt()}, - {"TREE", sdkmath.OneInt()}, - {"gAs", sdkmath.OneInt()}, + {"MineraL", sdk.OneInt()}, + {"TREE", sdk.OneInt()}, + {"gAs", sdk.OneInt()}, }, true, }, { "mixed case (2)", sdk.Coins{ - {"gAs", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"gAs", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, true, }, { "mixed case (3)", sdk.Coins{ - {"gAs", sdkmath.OneInt()}, + {"gAs", sdk.OneInt()}, }, true, }, { "unicode letters and numbers", sdk.Coins{ - {"𐀀𐀆𐀉Ⅲ", sdkmath.OneInt()}, + {"𐀀𐀆𐀉Ⅲ", sdk.OneInt()}, }, false, }, { "emojis", sdk.Coins{ - {"🤑😋🤔", sdkmath.OneInt()}, + {"🤑😋🤔", sdk.OneInt()}, }, false, }, { "IBC denominations (ADR 001)", sdk.Coins{ - {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.OneInt()}, - {"ibc/876563AAAACF739EB061C67CDB5EDF2B7C9FD4AA9D876450CC21210807C2820A", sdkmath.NewInt(2)}, + {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, + {"ibc/876563AAAACF739EB061C67CDB5EDF2B7C9FD4AA9D876450CC21210807C2820A", sdk.NewInt(2)}, }, true, }, @@ -637,61 +636,61 @@ func (s *coinTestSuite) TestCoins_Validate() { { "invalid denomination (1)", sdk.Coins{ - {"MineraL", sdkmath.OneInt()}, - {"0TREE", sdkmath.OneInt()}, - {"gAs", sdkmath.OneInt()}, + {"MineraL", sdk.OneInt()}, + {"0TREE", sdk.OneInt()}, + {"gAs", sdk.OneInt()}, }, false, }, { "invalid denomination (2)", sdk.Coins{ - {"-GAS", sdkmath.OneInt()}, - {"gAs", sdkmath.OneInt()}, + {"-GAS", sdk.OneInt()}, + {"gAs", sdk.OneInt()}, }, false, }, { "bad sort (1)", sdk.Coins{ - {"tree", sdkmath.OneInt()}, - {"gas", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"tree", sdk.OneInt()}, + {"gas", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, false, }, { "bad sort (2)", sdk.Coins{ - {"gas", sdkmath.OneInt()}, - {"tree", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"gas", sdk.OneInt()}, + {"tree", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, false, }, { "non-positive amount (1)", sdk.Coins{ - {"gas", sdkmath.OneInt()}, - {"tree", sdkmath.NewInt(0)}, - {"mineral", sdkmath.OneInt()}, + {"gas", sdk.OneInt()}, + {"tree", sdk.NewInt(0)}, + {"mineral", sdk.OneInt()}, }, false, }, { "non-positive amount (2)", sdk.Coins{ - {"gas", sdkmath.NewInt(-1)}, - {"tree", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"gas", sdk.NewInt(-1)}, + {"tree", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, false, }, { "duplicate denomination", sdk.Coins{ - {"gas", sdkmath.OneInt()}, - {"gas", sdkmath.OneInt()}, - {"mineral", sdkmath.OneInt()}, + {"gas", sdk.OneInt()}, + {"gas", sdk.OneInt()}, + {"mineral", sdk.OneInt()}, }, false, }, @@ -708,8 +707,8 @@ func (s *coinTestSuite) TestCoins_Validate() { } func (s *coinTestSuite) TestMinMax() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) cases := []struct { name string @@ -735,8 +734,8 @@ func (s *coinTestSuite) TestMinMax() { } func (s *coinTestSuite) TestCoinsGT() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGT(sdk.Coins{})) @@ -747,8 +746,8 @@ func (s *coinTestSuite) TestCoinsGT() { } func (s *coinTestSuite) TestCoinsLT() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllLT(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAllLT(sdk.Coins{})) @@ -762,8 +761,8 @@ func (s *coinTestSuite) TestCoinsLT() { } func (s *coinTestSuite) TestCoinsLTE() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().True(sdk.Coins{}.IsAllLTE(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAllLTE(sdk.Coins{})) @@ -777,7 +776,7 @@ func (s *coinTestSuite) TestCoinsLTE() { } func (s *coinTestSuite) TestParseCoins() { - one := sdkmath.OneInt() + one := sdk.OneInt() cases := []struct { input string @@ -786,7 +785,7 @@ func (s *coinTestSuite) TestParseCoins() { }{ {"", true, nil}, {"0stake", true, sdk.Coins{}}, // remove zero coins - {"0stake,1foo,99bar", true, sdk.Coins{{"bar", sdkmath.NewInt(99)}, {"foo", one}}}, // remove zero coins + {"0stake,1foo,99bar", true, sdk.Coins{{"bar", sdk.NewInt(99)}, {"foo", one}}}, // remove zero coins {"1foo", true, sdk.Coins{{"foo", one}}}, {"10btc,1atom,20btc", false, nil}, {"10bar", true, sdk.Coins{{"bar", sdk.NewInt(10)}}}, @@ -912,17 +911,17 @@ func (s *coinTestSuite) TestAmountOf() { } for _, tc := range cases { - s.Require().Equal(sdkmath.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas")) - s.Require().Equal(sdkmath.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral")) - s.Require().Equal(sdkmath.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree")) + s.Require().Equal(sdk.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas")) + s.Require().Equal(sdk.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral")) + s.Require().Equal(sdk.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree")) } s.Require().Panics(func() { cases[0].coins.AmountOf("10Invalid") }) } func (s *coinTestSuite) TestCoinsIsAnyGTE() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAnyGTE(sdk.Coins{})) s.Require().False(sdk.Coins{{testDenom1, one}}.IsAnyGTE(sdk.Coins{})) @@ -941,8 +940,8 @@ func (s *coinTestSuite) TestCoinsIsAnyGTE() { } func (s *coinTestSuite) TestCoinsIsAllGT() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGT(sdk.Coins{})) @@ -961,8 +960,8 @@ func (s *coinTestSuite) TestCoinsIsAllGT() { } func (s *coinTestSuite) TestCoinsIsAllGTE() { - one := sdkmath.OneInt() - two := sdkmath.NewInt(2) + one := sdk.OneInt() + two := sdk.NewInt(2) s.Require().True(sdk.Coins{}.IsAllGTE(sdk.Coins{})) s.Require().True(sdk.Coins{{testDenom1, one}}.IsAllGTE(sdk.Coins{})) @@ -986,7 +985,7 @@ func (s *coinTestSuite) TestNewCoins() { tenatom := sdk.NewInt64Coin("atom", 10) tenbtc := sdk.NewInt64Coin("btc", 10) zeroeth := sdk.NewInt64Coin("eth", 0) - invalidCoin := sdk.Coin{"0ETH", sdkmath.OneInt()} + invalidCoin := sdk.Coin{"0ETH", sdk.OneInt()} tests := []struct { name string coins sdk.Coins diff --git a/types/dec_coin.go b/types/dec_coin.go index 2866fd51e7a3..387d9dfa2dd3 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -6,8 +6,6 @@ import ( "strings" "github.com/pkg/errors" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) // ---------------------------------------------------------------------------- @@ -52,7 +50,7 @@ func NewDecCoinFromCoin(coin Coin) DecCoin { // NewInt64DecCoin returns a new DecCoin with a denomination and amount. It will // panic if the amount is negative or denom is invalid. func NewInt64DecCoin(denom string, amount int64) DecCoin { - return NewDecCoin(denom, sdkmath.NewInt(amount)) + return NewDecCoin(denom, NewInt(amount)) } // IsZero returns if the DecCoin amount is zero. diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index d46ba1c8df11..52f50d24fc22 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/suite" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -50,16 +49,16 @@ func (s *decCoinTestSuite) TestNewDecCoinFromDec() { func (s *decCoinTestSuite) TestNewDecCoinFromCoin() { s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(5)}) }) s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(0)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(0)}) }) s.Require().NotPanics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{strings.ToUpper(testDenom1), sdkmath.NewInt(5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{strings.ToUpper(testDenom1), sdk.NewInt(5)}) }) s.Require().Panics(func() { - sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdkmath.NewInt(-5)}) + sdk.NewDecCoinFromCoin(sdk.Coin{testDenom1, sdk.NewInt(-5)}) }) } @@ -188,7 +187,7 @@ func (s *decCoinTestSuite) TestIsValid() { msg string }{ { - sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)), + sdk.NewDecCoin("mytoken", sdk.NewInt(10)), true, "valid coins should have passed", }, @@ -226,23 +225,23 @@ func (s *decCoinTestSuite) TestSubDecCoin() { msg string }{ { - sdk.NewDecCoin("mytoken", sdkmath.NewInt(20)), + sdk.NewDecCoin("mytoken", sdk.NewInt(20)), true, "valid coins should have passed", }, { - sdk.NewDecCoin("othertoken", sdkmath.NewInt(20)), + sdk.NewDecCoin("othertoken", sdk.NewInt(20)), false, "denom mismatch", }, { - sdk.NewDecCoin("mytoken", sdkmath.NewInt(9)), + sdk.NewDecCoin("mytoken", sdk.NewInt(9)), false, "negative amount", }, } - decCoin := sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)) + decCoin := sdk.NewDecCoin("mytoken", sdk.NewInt(10)) for _, tc := range tests { tc := tc @@ -262,23 +261,23 @@ func (s *decCoinTestSuite) TestSubDecCoins() { msg string }{ { - sdk.NewDecCoinsFromCoins(sdk.NewCoin("mytoken", sdkmath.NewInt(10)), sdk.NewCoin("btc", sdkmath.NewInt(20)), sdk.NewCoin("eth", sdkmath.NewInt(30))), + sdk.NewDecCoinsFromCoins(sdk.NewCoin("mytoken", sdk.NewInt(10)), sdk.NewCoin("btc", sdk.NewInt(20)), sdk.NewCoin("eth", sdk.NewInt(30))), true, "sorted coins should have passed", }, { - sdk.DecCoins{sdk.NewDecCoin("mytoken", sdkmath.NewInt(10)), sdk.NewDecCoin("btc", sdkmath.NewInt(20)), sdk.NewDecCoin("eth", sdkmath.NewInt(30))}, + sdk.DecCoins{sdk.NewDecCoin("mytoken", sdk.NewInt(10)), sdk.NewDecCoin("btc", sdk.NewInt(20)), sdk.NewDecCoin("eth", sdk.NewInt(30))}, false, "unorted coins should panic", }, { - sdk.DecCoins{sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}, sdk.NewDecCoin("eth", sdkmath.NewInt(15)), sdk.NewDecCoin("mytoken", sdkmath.NewInt(5))}, + sdk.DecCoins{sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}, sdk.NewDecCoin("eth", sdk.NewInt(15)), sdk.NewDecCoin("mytoken", sdk.NewInt(5))}, false, "invalid denoms", }, } - decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", sdkmath.NewInt(10)), sdk.NewCoin("eth", sdkmath.NewInt(15)), sdk.NewCoin("mytoken", sdkmath.NewInt(5))) + decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", sdk.NewInt(10)), sdk.NewCoin("eth", sdk.NewInt(15)), sdk.NewCoin("mytoken", sdk.NewInt(5))) for _, tc := range tests { tc := tc @@ -375,7 +374,7 @@ func (s *decCoinTestSuite) TestParseDecCoins() { expectedErr bool }{ {"", nil, false}, - {"4stake", sdk.DecCoins{sdk.NewDecCoinFromDec("stake", sdk.NewDecFromInt(sdkmath.NewInt(4)))}, false}, + {"4stake", sdk.DecCoins{sdk.NewDecCoinFromDec("stake", sdk.NewDecFromInt(sdk.NewInt(4)))}, false}, {"5.5atom,4stake", sdk.DecCoins{ sdk.NewDecCoinFromDec("atom", sdk.NewDecWithPrec(5500000000000000000, sdk.Precision)), sdk.NewDecCoinFromDec("stake", sdk.NewDec(4)), @@ -533,8 +532,8 @@ func (s *decCoinTestSuite) TestDecCoinsQuoDecTruncate() { } func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { - fake1 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), sdk.DecCoin{Denom: "10BTC", Amount: sdk.NewDec(10)}) - fake2 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}) + fake1 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), sdk.DecCoin{Denom: "10BTC", Amount: sdk.NewDec(10)}) + fake2 := append(sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}) tests := []struct { coin sdk.DecCoins @@ -542,7 +541,7 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { msg string }{ { - sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), + sdk.NewDecCoins(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), true, "valid coins should have passed", }, @@ -569,7 +568,7 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { } func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { - lengthTestDecCoins := sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}) + lengthTestDecCoins := sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}) s.Require().Equal(2, len(lengthTestDecCoins), "should be 2") tests := []struct { @@ -578,17 +577,17 @@ func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { msg string }{ { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))), true, "valid coins should have passed", }, { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "0BTC", Amount: sdk.NewDec(10)}), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "0BTC", Amount: sdk.NewDec(10)}), false, "invalid denoms", }, { - sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdkmath.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}), + sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(-10)}), false, "negative amount", }, diff --git a/types/decimal.go b/types/decimal.go index 4c41b661302d..02edd99d6aca 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -8,8 +8,6 @@ import ( "strconv" "strings" "testing" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) var _ CustomProtobufType = (*Dec)(nil) @@ -33,7 +31,7 @@ const ( // Floor[Log2[10^Precision - 1]]. decimalTruncateBits = DecimalPrecisionBits - 1 - maxDecBitLen = sdkmath.MaxBitLen + decimalTruncateBits + maxDecBitLen = MaxBitLen + decimalTruncateBits // max number of iterations in ApproxRoot function maxApproxRootIterations = 100 @@ -659,7 +657,7 @@ func (d Dec) RoundInt64() int64 { // RoundInt round the decimal using bankers rounding func (d Dec) RoundInt() Int { - return sdkmath.NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) + return NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) } // chopPrecisionAndTruncate is similar to chopPrecisionAndRound, @@ -685,7 +683,7 @@ func (d Dec) TruncateInt64() int64 { // TruncateInt truncates the decimals from the number and returns an Int func (d Dec) TruncateInt() Int { - return sdkmath.NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.i)) + return NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.i)) } // TruncateDec truncates the decimals from the number and returns a Dec diff --git a/types/decimal_test.go b/types/decimal_test.go index 63e97a8440df..684888b49363 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/suite" "sigs.k8s.io/yaml" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -348,10 +347,10 @@ func (s *decimalTestSuite) TestDecMulInt() { sdkInt sdk.Int want sdk.Dec }{ - {sdk.NewDec(10), sdkmath.NewInt(2), sdk.NewDec(20)}, - {sdk.NewDec(1000000), sdkmath.NewInt(100), sdk.NewDec(100000000)}, - {sdk.NewDecWithPrec(1, 1), sdkmath.NewInt(10), sdk.NewDec(1)}, - {sdk.NewDecWithPrec(1, 5), sdkmath.NewInt(20), sdk.NewDecWithPrec(2, 4)}, + {sdk.NewDec(10), sdk.NewInt(2), sdk.NewDec(20)}, + {sdk.NewDec(1000000), sdk.NewInt(100), sdk.NewDec(100000000)}, + {sdk.NewDecWithPrec(1, 1), sdk.NewInt(10), sdk.NewDec(1)}, + {sdk.NewDecWithPrec(1, 5), sdk.NewInt(20), sdk.NewDecWithPrec(2, 4)}, } for i, tc := range tests { got := tc.sdkDec.MulInt(tc.sdkInt) @@ -386,13 +385,13 @@ func (s *decimalTestSuite) TestPower() { power uint64 expected sdk.Dec }{ - {sdk.NewDec(100), 0, sdk.OneDec()}, // 10 ^ (0) => 1.0 - {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (10) => 1.0 - {sdk.NewDecWithPrec(5, 1), 2, sdk.NewDecWithPrec(25, 2)}, // 0.5 ^ 2 => 0.25 - {sdk.NewDecWithPrec(2, 1), 2, sdk.NewDecWithPrec(4, 2)}, // 0.2 ^ 2 => 0.04 - {sdk.NewDecFromInt(sdkmath.NewInt(3)), 3, sdk.NewDecFromInt(sdkmath.NewInt(27))}, // 3 ^ 3 => 27 - {sdk.NewDecFromInt(sdkmath.NewInt(-3)), 4, sdk.NewDecFromInt(sdkmath.NewInt(81))}, // -3 ^ 4 = 81 - {sdk.NewDecWithPrec(1414213562373095049, 18), 2, sdk.NewDecFromInt(sdkmath.NewInt(2))}, // 1.414213562373095049 ^ 2 = 2 + {sdk.NewDec(100), 0, sdk.OneDec()}, // 10 ^ (0) => 1.0 + {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (10) => 1.0 + {sdk.NewDecWithPrec(5, 1), 2, sdk.NewDecWithPrec(25, 2)}, // 0.5 ^ 2 => 0.25 + {sdk.NewDecWithPrec(2, 1), 2, sdk.NewDecWithPrec(4, 2)}, // 0.2 ^ 2 => 0.04 + {sdk.NewDecFromInt(sdk.NewInt(3)), 3, sdk.NewDecFromInt(sdk.NewInt(27))}, // 3 ^ 3 => 27 + {sdk.NewDecFromInt(sdk.NewInt(-3)), 4, sdk.NewDecFromInt(sdk.NewInt(81))}, // -3 ^ 4 = 81 + {sdk.NewDecWithPrec(1414213562373095049, 18), 2, sdk.NewDecFromInt(sdk.NewInt(2))}, // 1.414213562373095049 ^ 2 = 2 } for i, tc := range testCases { @@ -416,9 +415,9 @@ func (s *decimalTestSuite) TestApproxRoot() { {sdk.OneDec(), 10, sdk.OneDec()}, // 1.0 ^ (0.1) => 1.0 {sdk.NewDecWithPrec(25, 2), 2, sdk.NewDecWithPrec(5, 1)}, // 0.25 ^ (0.5) => 0.5 {sdk.NewDecWithPrec(4, 2), 2, sdk.NewDecWithPrec(2, 1)}, // 0.04 ^ (0.5) => 0.2 - {sdk.NewDecFromInt(sdkmath.NewInt(27)), 3, sdk.NewDecFromInt(sdkmath.NewInt(3))}, // 27 ^ (1/3) => 3 - {sdk.NewDecFromInt(sdkmath.NewInt(-81)), 4, sdk.NewDecFromInt(sdkmath.NewInt(-3))}, // -81 ^ (0.25) => -3 - {sdk.NewDecFromInt(sdkmath.NewInt(2)), 2, sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 ^ (0.5) => 1.414213562373095049 + {sdk.NewDecFromInt(sdk.NewInt(27)), 3, sdk.NewDecFromInt(sdk.NewInt(3))}, // 27 ^ (1/3) => 3 + {sdk.NewDecFromInt(sdk.NewInt(-81)), 4, sdk.NewDecFromInt(sdk.NewInt(-3))}, // -81 ^ (0.25) => -3 + {sdk.NewDecFromInt(sdk.NewInt(2)), 2, sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 ^ (0.5) => 1.414213562373095049 {sdk.NewDecWithPrec(1005, 3), 31536000, sdk.MustNewDecFromStr("1.000000000158153904")}, // 1.005 ^ (1/31536000) ≈ 1.00000000016 {sdk.SmallestDec(), 2, sdk.NewDecWithPrec(1, 9)}, // 1e-18 ^ (0.5) => 1e-9 {sdk.SmallestDec(), 3, sdk.MustNewDecFromStr("0.000000999999999997")}, // 1e-18 ^ (1/3) => 1e-6 @@ -441,12 +440,12 @@ func (s *decimalTestSuite) TestApproxSqrt() { input sdk.Dec expected sdk.Dec }{ - {sdk.OneDec(), sdk.OneDec()}, // 1.0 => 1.0 - {sdk.NewDecWithPrec(25, 2), sdk.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 - {sdk.NewDecWithPrec(4, 2), sdk.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 - {sdk.NewDecFromInt(sdkmath.NewInt(9)), sdk.NewDecFromInt(sdkmath.NewInt(3))}, // 9 => 3 - {sdk.NewDecFromInt(sdkmath.NewInt(-9)), sdk.NewDecFromInt(sdkmath.NewInt(-3))}, // -9 => -3 - {sdk.NewDecFromInt(sdkmath.NewInt(2)), sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 + {sdk.OneDec(), sdk.OneDec()}, // 1.0 => 1.0 + {sdk.NewDecWithPrec(25, 2), sdk.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 + {sdk.NewDecWithPrec(4, 2), sdk.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 + {sdk.NewDecFromInt(sdk.NewInt(9)), sdk.NewDecFromInt(sdk.NewInt(3))}, // 9 => 3 + {sdk.NewDecFromInt(sdk.NewInt(-9)), sdk.NewDecFromInt(sdk.NewInt(-3))}, // -9 => -3 + {sdk.NewDecFromInt(sdk.NewInt(2)), sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 } for i, tc := range testCases { diff --git a/types/denom_internal_test.go b/types/denom_internal_test.go index da800e6ea298..8c957353ebc7 100644 --- a/types/denom_internal_test.go +++ b/types/denom_internal_test.go @@ -4,8 +4,6 @@ import ( "testing" "github.com/stretchr/testify/suite" - - sdkmath "github.com/cosmos/cosmos-sdk/math" ) var ( @@ -58,16 +56,16 @@ func (s *internalDenomTestSuite) TestConvertCoins() { res, err := GetBaseDenom() s.Require().NoError(err) s.Require().Equal(res, natom) - s.Require().Equal(NormalizeCoin(NewCoin(uatom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000))) - s.Require().Equal(NormalizeCoin(NewCoin(matom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000000))) - s.Require().Equal(NormalizeCoin(NewCoin(atom, sdkmath.NewInt(1))), NewCoin(natom, sdkmath.NewInt(1000000000))) + s.Require().Equal(NormalizeCoin(NewCoin(uatom, NewInt(1))), NewCoin(natom, NewInt(1000))) + s.Require().Equal(NormalizeCoin(NewCoin(matom, NewInt(1))), NewCoin(natom, NewInt(1000000))) + s.Require().Equal(NormalizeCoin(NewCoin(atom, NewInt(1))), NewCoin(natom, NewInt(1000000000))) coins, err := ParseCoinsNormalized("1atom,1matom,1uatom") s.Require().NoError(err) s.Require().Equal(coins, Coins{ - Coin{natom, sdkmath.NewInt(1000000000)}, - Coin{natom, sdkmath.NewInt(1000000)}, - Coin{natom, sdkmath.NewInt(1000)}, + Coin{natom, NewInt(1000000000)}, + Coin{natom, NewInt(1000000)}, + Coin{natom, NewInt(1000)}, }) testCases := []struct { @@ -76,20 +74,20 @@ func (s *internalDenomTestSuite) TestConvertCoins() { result Coin expErr bool }{ - {NewCoin("foo", sdkmath.ZeroInt()), atom, Coin{}, true}, - {NewCoin(atom, sdkmath.ZeroInt()), "foo", Coin{}, true}, - {NewCoin(atom, sdkmath.ZeroInt()), "FOO", Coin{}, true}, + {NewCoin("foo", ZeroInt()), atom, Coin{}, true}, + {NewCoin(atom, ZeroInt()), "foo", Coin{}, true}, + {NewCoin(atom, ZeroInt()), "FOO", Coin{}, true}, - {NewCoin(atom, sdkmath.NewInt(5)), matom, NewCoin(matom, sdkmath.NewInt(5000)), false}, // atom => matom - {NewCoin(atom, sdkmath.NewInt(5)), uatom, NewCoin(uatom, sdkmath.NewInt(5000000)), false}, // atom => uatom - {NewCoin(atom, sdkmath.NewInt(5)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // atom => natom + {NewCoin(atom, NewInt(5)), matom, NewCoin(matom, NewInt(5000)), false}, // atom => matom + {NewCoin(atom, NewInt(5)), uatom, NewCoin(uatom, NewInt(5000000)), false}, // atom => uatom + {NewCoin(atom, NewInt(5)), natom, NewCoin(natom, NewInt(5000000000)), false}, // atom => natom - {NewCoin(uatom, sdkmath.NewInt(5000000)), matom, NewCoin(matom, sdkmath.NewInt(5000)), false}, // uatom => matom - {NewCoin(uatom, sdkmath.NewInt(5000000)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // uatom => natom - {NewCoin(uatom, sdkmath.NewInt(5000000)), atom, NewCoin(atom, sdkmath.NewInt(5)), false}, // uatom => atom + {NewCoin(uatom, NewInt(5000000)), matom, NewCoin(matom, NewInt(5000)), false}, // uatom => matom + {NewCoin(uatom, NewInt(5000000)), natom, NewCoin(natom, NewInt(5000000000)), false}, // uatom => natom + {NewCoin(uatom, NewInt(5000000)), atom, NewCoin(atom, NewInt(5)), false}, // uatom => atom - {NewCoin(matom, sdkmath.NewInt(5000)), natom, NewCoin(natom, sdkmath.NewInt(5000000000)), false}, // matom => natom - {NewCoin(matom, sdkmath.NewInt(5000)), uatom, NewCoin(uatom, sdkmath.NewInt(5000000)), false}, // matom => uatom + {NewCoin(matom, NewInt(5000)), natom, NewCoin(natom, NewInt(5000000000)), false}, // matom => natom + {NewCoin(matom, NewInt(5000)), uatom, NewCoin(uatom, NewInt(5000000)), false}, // matom => uatom } for i, tc := range testCases { @@ -125,16 +123,16 @@ func (s *internalDenomTestSuite) TestConvertDecCoins() { res, err := GetBaseDenom() s.Require().NoError(err) s.Require().Equal(res, natom) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(uatom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000))) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(matom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000000))) - s.Require().Equal(NormalizeDecCoin(NewDecCoin(atom, sdkmath.NewInt(1))), NewDecCoin(natom, sdkmath.NewInt(1000000000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(uatom, NewInt(1))), NewDecCoin(natom, NewInt(1000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(matom, NewInt(1))), NewDecCoin(natom, NewInt(1000000))) + s.Require().Equal(NormalizeDecCoin(NewDecCoin(atom, NewInt(1))), NewDecCoin(natom, NewInt(1000000000))) coins, err := ParseCoinsNormalized("0.1atom,0.1matom,0.1uatom") s.Require().NoError(err) s.Require().Equal(coins, Coins{ - Coin{natom, sdkmath.NewInt(100000000)}, - Coin{natom, sdkmath.NewInt(100000)}, - Coin{natom, sdkmath.NewInt(100)}, + Coin{natom, NewInt(100000000)}, + Coin{natom, NewInt(100000)}, + Coin{natom, NewInt(100)}, }) testCases := []struct { @@ -143,21 +141,21 @@ func (s *internalDenomTestSuite) TestConvertDecCoins() { result DecCoin expErr bool }{ - {NewDecCoin("foo", sdkmath.ZeroInt()), atom, DecCoin{}, true}, - {NewDecCoin(atom, sdkmath.ZeroInt()), "foo", DecCoin{}, true}, - {NewDecCoin(atom, sdkmath.ZeroInt()), "FOO", DecCoin{}, true}, + {NewDecCoin("foo", ZeroInt()), atom, DecCoin{}, true}, + {NewDecCoin(atom, ZeroInt()), "foo", DecCoin{}, true}, + {NewDecCoin(atom, ZeroInt()), "FOO", DecCoin{}, true}, // 0.5atom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), matom, NewDecCoin(matom, sdkmath.NewInt(500)), false}, // atom => matom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), uatom, NewDecCoin(uatom, sdkmath.NewInt(500000)), false}, // atom => uatom - {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), natom, NewDecCoin(natom, sdkmath.NewInt(500000000)), false}, // atom => natom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), matom, NewDecCoin(matom, NewInt(500)), false}, // atom => matom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), uatom, NewDecCoin(uatom, NewInt(500000)), false}, // atom => uatom + {NewDecCoinFromDec(atom, NewDecWithPrec(5, 1)), natom, NewDecCoin(natom, NewInt(500000000)), false}, // atom => natom - {NewDecCoin(uatom, sdkmath.NewInt(5000000)), matom, NewDecCoin(matom, sdkmath.NewInt(5000)), false}, // uatom => matom - {NewDecCoin(uatom, sdkmath.NewInt(5000000)), natom, NewDecCoin(natom, sdkmath.NewInt(5000000000)), false}, // uatom => natom - {NewDecCoin(uatom, sdkmath.NewInt(5000000)), atom, NewDecCoin(atom, sdkmath.NewInt(5)), false}, // uatom => atom + {NewDecCoin(uatom, NewInt(5000000)), matom, NewDecCoin(matom, NewInt(5000)), false}, // uatom => matom + {NewDecCoin(uatom, NewInt(5000000)), natom, NewDecCoin(natom, NewInt(5000000000)), false}, // uatom => natom + {NewDecCoin(uatom, NewInt(5000000)), atom, NewDecCoin(atom, NewInt(5)), false}, // uatom => atom - {NewDecCoin(matom, sdkmath.NewInt(5000)), natom, NewDecCoin(natom, sdkmath.NewInt(5000000000)), false}, // matom => natom - {NewDecCoin(matom, sdkmath.NewInt(5000)), uatom, NewDecCoin(uatom, sdkmath.NewInt(5000000)), false}, // matom => uatom + {NewDecCoin(matom, NewInt(5000)), natom, NewDecCoin(natom, NewInt(5000000000)), false}, // matom => natom + {NewDecCoin(matom, NewInt(5000)), uatom, NewDecCoin(uatom, NewInt(5000000)), false}, // matom => uatom } for i, tc := range testCases { @@ -184,9 +182,9 @@ func (s *internalDenomTestSuite) TestDecOperationOrder() { dec, err = NewDecFromStr("100000011") s.Require().NoError(RegisterDenom("unit2", dec)) - coin, err := ConvertCoin(NewCoin("unit1", sdkmath.NewInt(100000011)), "unit2") + coin, err := ConvertCoin(NewCoin("unit1", NewInt(100000011)), "unit2") s.Require().NoError(err) - s.Require().Equal(coin, NewCoin("unit2", sdkmath.NewInt(11))) + s.Require().Equal(coin, NewCoin("unit2", NewInt(11))) // reset registration baseDenom = "" diff --git a/types/events_test.go b/types/events_test.go index 16e4b328af64..87622550d26a 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -9,7 +9,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdkmath "github.com/cosmos/cosmos-sdk/math" testdata "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -75,7 +74,7 @@ func (s *eventsTestSuite) TestEventManager() { func (s *eventsTestSuite) TestEventManagerTypedEvents() { em := sdk.NewEventManager() - coin := sdk.NewCoin("fakedenom", sdkmath.NewInt(1999999)) + coin := sdk.NewCoin("fakedenom", sdk.NewInt(1999999)) cat := testdata.Cat{ Moniker: "Garfield", Lives: 6, diff --git a/types/math.go b/types/math.go index 0392b0d1f640..8b8ba4b66031 100644 --- a/types/math.go +++ b/types/math.go @@ -18,6 +18,16 @@ type ( var ( NewIntFromBigInt = sdkmath.NewIntFromBigInt OneInt = sdkmath.OneInt + NewInt = sdkmath.NewInt + ZeroInt = sdkmath.ZeroInt + IntEq = sdkmath.IntEq + NewIntFromString = sdkmath.NewIntFromString + NewUint = sdkmath.NewUint + NewIntFromUint64 = sdkmath.NewIntFromUint64 +) + +const ( + MaxBitLen = sdkmath.MaxBitLen ) func (ip IntProto) String() string { diff --git a/types/staking.go b/types/staking.go index f69ef8b5217c..2f17bb1dd85f 100644 --- a/types/staking.go +++ b/types/staking.go @@ -1,9 +1,5 @@ package types -import ( - sdkmath "github.com/cosmos/cosmos-sdk/math" -) - // staking constants const ( @@ -23,7 +19,7 @@ const ( ) // DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power -var DefaultPowerReduction = sdkmath.NewIntFromUint64(1000000) +var DefaultPowerReduction = NewIntFromUint64(1000000) // TokensToConsensusPower - convert input tokens to potential consensus-engine power func TokensToConsensusPower(tokens Int, powerReduction Int) int64 { @@ -32,5 +28,5 @@ func TokensToConsensusPower(tokens Int, powerReduction Int) int64 { // TokensFromConsensusPower - convert input power to tokens func TokensFromConsensusPower(power int64, powerReduction Int) Int { - return sdkmath.NewInt(power).Mul(powerReduction) + return NewInt(power).Mul(powerReduction) } diff --git a/types/staking_test.go b/types/staking_test.go index 22757263a573..fe6c36bd991b 100644 --- a/types/staking_test.go +++ b/types/staking_test.go @@ -5,7 +5,6 @@ import ( "github.com/stretchr/testify/suite" - sdkmath "github.com/cosmos/cosmos-sdk/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -22,6 +21,6 @@ func (s *stakingTestSuite) SetupSuite() { } func (s *stakingTestSuite) TestTokensToConsensusPower() { - s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdkmath.NewInt(999_999), sdk.DefaultPowerReduction)) - s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdkmath.NewInt(1_000_000), sdk.DefaultPowerReduction)) + s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999), sdk.DefaultPowerReduction)) + s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000), sdk.DefaultPowerReduction)) } From c81d735587e02727a494d9ea612160cc7b661303 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:25:59 -0400 Subject: [PATCH 16/22] updates --- types/dec_coin.go | 6 +++--- types/denom.go | 2 +- types/math.go | 5 ----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/types/dec_coin.go b/types/dec_coin.go index 387d9dfa2dd3..99c77a970668 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -17,7 +17,7 @@ func NewDecCoin(denom string, amount Int) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: ToDec(coin.Amount), + Amount: NewDecFromInt(coin.Amount), } } @@ -43,7 +43,7 @@ func NewDecCoinFromCoin(coin Coin) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: ToDec(coin.Amount), + Amount: NewDecFromInt(coin.Amount), } } @@ -111,7 +111,7 @@ func (coin DecCoin) Sub(coinB DecCoin) DecCoin { // change. Note, the change may be zero. func (coin DecCoin) TruncateDecimal() (Coin, DecCoin) { truncated := coin.Amount.TruncateInt() - change := coin.Amount.Sub(ToDec(truncated)) + change := coin.Amount.Sub(NewDecFromInt(truncated)) return NewCoin(coin.Denom, truncated), NewDecCoinFromDec(coin.Denom, change) } diff --git a/types/denom.go b/types/denom.go index bfb2ff30e14b..df25dd4b55ed 100644 --- a/types/denom.go +++ b/types/denom.go @@ -75,7 +75,7 @@ func ConvertCoin(coin Coin, denom string) (Coin, error) { return NewCoin(denom, coin.Amount), nil } - return NewCoin(denom, ToDec(coin.Amount).Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil + return NewCoin(denom, NewDecFromInt(coin.Amount).Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil } // ConvertDecCoin attempts to convert a decimal coin to a given denomination. If the given diff --git a/types/math.go b/types/math.go index 8b8ba4b66031..aaf6630e4096 100644 --- a/types/math.go +++ b/types/math.go @@ -33,8 +33,3 @@ const ( func (ip IntProto) String() string { return ip.Int.String() } - -// ToDec converts an Int type to a Dec type. -func ToDec(i Int) Dec { - return NewDecFromInt(i) -} From e724139c4f8d4160a4cd20037184e4af68c7bdc6 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:27:54 -0400 Subject: [PATCH 17/22] updates --- types/math.go | 2 ++ x/auth/vesting/types/vesting_account.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/math.go b/types/math.go index aaf6630e4096..3cd650f4a111 100644 --- a/types/math.go +++ b/types/math.go @@ -24,6 +24,8 @@ var ( NewIntFromString = sdkmath.NewIntFromString NewUint = sdkmath.NewUint NewIntFromUint64 = sdkmath.NewIntFromUint64 + MaxInt = sdkmath.MaxInt + MinInt = sdkmath.MinInt ) const ( diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 7316e6afd5b7..342ddce28b0d 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -238,7 +238,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin s := sdk.NewDec(x).Quo(sdk.NewDec(y)) for _, ovc := range cva.OriginalVesting { - vestedAmt := ovc.Amount.ToDec().Mul(s).RoundInt() + vestedAmt := sdk.NewDecFromInt(ovc.Amount).Mul(s).RoundInt() vestedCoins = append(vestedCoins, sdk.NewCoin(ovc.Denom, vestedAmt)) } From 6701e0311e7a43c1570f7320b85e15f48776cde3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:29:23 -0400 Subject: [PATCH 18/22] updates --- x/distribution/keeper/delegation_test.go | 16 ++++++++-------- x/distribution/keeper/validator.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index a1916913c424..7b18c0241f3b 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -117,7 +117,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { // allocate some rewards initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}} + tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) // end period @@ -127,10 +127,10 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) // rewards should be half the tokens - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, rewards) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial.QuoRaw(2))}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial.QuoRaw(2))}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission) } @@ -180,7 +180,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { // allocate some rewards initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}} + tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) // slash the validator by 50% again @@ -202,10 +202,10 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) // rewards should be half the tokens - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, rewards) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission) } @@ -381,7 +381,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3) // allocate some rewards - initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec() + initial := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)) tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) @@ -437,7 +437,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0]) // allocate some rewards - initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 30).ToDec() + initial := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 30)) tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 3d1953c3b5fa..38654e771a0b 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -45,7 +45,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.Valid current = sdk.DecCoins{} } else { // note: necessary to truncate so we don't allow withdrawing more rewards than owed - current = rewards.Rewards.QuoDecTruncate(val.GetTokens().ToDec()) + current = rewards.Rewards.QuoDecTruncate(sdk.NewDecFromInt(val.GetTokens())) } // fetch historical rewards for last period From 0ae8166bb3890e5bce17a5cfb5342dafdcdba444 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 15:34:28 -0400 Subject: [PATCH 19/22] updates --- x/gov/keeper/tally.go | 2 +- x/staking/app_test.go | 2 +- x/staking/genesis_test.go | 8 ++++---- x/staking/keeper/delegation_test.go | 26 +++++++++++++------------- x/staking/keeper/grpc_query_test.go | 10 +++++----- x/staking/keeper/pool.go | 2 +- x/staking/keeper/slash.go | 4 ++-- x/staking/keeper/validator_test.go | 10 +++++----- x/staking/types/validator.go | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index 52d7138e8388..6b2b51f257e3 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -102,7 +102,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, } // If there is not enough quorum of votes, the proposal fails - percentVoting := totalVotingPower.Quo(keeper.sk.TotalBondedTokens(ctx).ToDec()) + percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(keeper.sk.TotalBondedTokens(ctx))) quorum, _ := sdk.NewDecFromStr(tallyParams.Quorum) if percentVoting.LT(quorum) { return false, false, tallyResults diff --git a/x/staking/app_test.go b/x/staking/app_test.go index a97954254826..ce737e3b6218 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -107,7 +107,7 @@ func TestStakingMsgs(t *testing.T) { require.NoError(t, err) simapp.CheckBalance(t, app, addr2, sdk.Coins{genCoin.Sub(bondCoin)}) - checkDelegation(t, app, addr2, sdk.ValAddress(addr1), true, bondTokens.ToDec()) + checkDelegation(t, app, addr2, sdk.ValAddress(addr1), true, sdk.NewDecFromInt(bondTokens)) // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin) diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index df6120b04361..24b794123a99 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -49,7 +49,7 @@ func TestInitGenesis(t *testing.T) { ConsensusPubkey: pk0, Status: types.Bonded, Tokens: valTokens, - DelegatorShares: valTokens.ToDec(), + DelegatorShares: sdk.NewDecFromInt(valTokens), Description: types.NewDescription("hoop", "", "", "", ""), } bondedVal2 := types.Validator{ @@ -57,7 +57,7 @@ func TestInitGenesis(t *testing.T) { ConsensusPubkey: pk1, Status: types.Bonded, Tokens: valTokens, - DelegatorShares: valTokens.ToDec(), + DelegatorShares: sdk.NewDecFromInt(valTokens), Description: types.NewDescription("bloop", "", "", "", ""), } @@ -126,7 +126,7 @@ func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { ConsensusPubkey: consPub, Jailed: false, Tokens: sdk.NewInt(10), - DelegatorShares: sdk.NewInt(10).ToDec(), + DelegatorShares: sdk.NewDecFromInt(sdk.NewInt(10)), Description: types.NewDescription("bloop", "", "", "", ""), } // valid params @@ -182,7 +182,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 2) } validators[i].Tokens = tokens - validators[i].DelegatorShares = tokens.ToDec() + validators[i].DelegatorShares = sdk.NewDecFromInt(tokens) // add bonded coins bondedPoolAmt = bondedPoolAmt.Add(tokens) } diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index 345121e4ed60..723caa693e1c 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -221,7 +221,7 @@ func TestUnbondDelegation(t *testing.T) { app.StakingKeeper.SetDelegation(ctx, delegation) bondTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - amount, err := app.StakingKeeper.Unbond(ctx, delAddrs[0], valAddrs[0], bondTokens.ToDec()) + amount, err := app.StakingKeeper.Unbond(ctx, delAddrs[0], valAddrs[0], sdk.NewDecFromInt(bondTokens)) require.NoError(t, err) require.Equal(t, bondTokens, amount) // shares to be added to an unbonding delegation @@ -364,7 +364,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { app.StakingKeeper.SetDelegation(ctx, delegation) val0AccAddr := sdk.AccAddress(addrVals[0].Bytes()) - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], app.StakingKeeper.TokensFromConsensusPower(ctx, 6).ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 6))) require.NoError(t, err) // end block @@ -433,7 +433,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { // unbond the all self-delegation to put validator in unbonding state val0AccAddr := sdk.AccAddress(addrVals[0]) - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -508,7 +508,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], valTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(valTokens)) require.NoError(t, err) // end block @@ -531,12 +531,12 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { // unbond some of the other delegation's shares unbondTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], unbondTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(unbondTokens)) require.NoError(t, err) // unbond rest of the other delegation's shares remainingTokens := delTokens.Sub(unbondTokens) - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], remainingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(remainingTokens)) require.NoError(t, err) // now validator should be deleted from state @@ -592,14 +592,14 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], valTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(valTokens)) require.NoError(t, err) // end block applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1) // unbond all the remaining delegation - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], delTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // validator should still be in state and still be in unbonding state @@ -836,7 +836,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) app.StakingKeeper.SetDelegation(ctx, delegation) - _, err := app.StakingKeeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], delTokens.ToDec()) + _, err := app.StakingKeeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -897,7 +897,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { ctx = ctx.WithBlockHeader(header) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -919,7 +919,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { // unbond some of the other delegation's shares redelegateTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], redelegateTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], sdk.NewDecFromInt(redelegateTokens)) require.NoError(t, err) // retrieve the unbonding delegation @@ -976,7 +976,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -993,7 +993,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { // redelegate some of the delegation's shares redelegationTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], redelegationTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], sdk.NewDecFromInt(redelegationTokens)) require.NoError(t, err) // no red should have been found diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index 8bb355571cd2..402e0dc0f2cd 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -422,7 +422,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryUnbondingDelegation() { unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) valAddr, err1 := sdk.ValAddressFromBech32(addrVal2) suite.NoError(err1) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc2, valAddr, unbondingTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc2, valAddr, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) unbond, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc2, valAddr) @@ -480,11 +480,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryDelegatorUnbondingDelegations() { unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) valAddr1, err1 := sdk.ValAddressFromBech32(addrVal) suite.NoError(err1) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr1, unbondingTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr1, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) valAddr2, err1 := sdk.ValAddressFromBech32(addrVal2) suite.NoError(err1) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr2, unbondingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr2, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) unbond, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc, valAddr1) @@ -632,7 +632,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) rdAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), rdAmount.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount)) suite.NoError(err) applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) @@ -724,7 +724,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() { // undelegate undelAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), undelAmount.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount)) suite.NoError(err) applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) diff --git a/x/staking/keeper/pool.go b/x/staking/keeper/pool.go index c24c87632358..b281b45784dc 100644 --- a/x/staking/keeper/pool.go +++ b/x/staking/keeper/pool.go @@ -71,7 +71,7 @@ func (k Keeper) StakingTokenSupply(ctx sdk.Context) sdk.Int { func (k Keeper) BondedRatio(ctx sdk.Context) sdk.Dec { stakeSupply := k.StakingTokenSupply(ctx) if stakeSupply.IsPositive() { - return k.TotalBondedTokens(ctx).ToDec().QuoInt(stakeSupply) + return sdk.NewDecFromInt(k.TotalBondedTokens(ctx)).QuoInt(stakeSupply) } return sdk.ZeroDec() diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 279af3a85a35..734af19f6f44 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -30,7 +30,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh // Amount of slashing = slash slashFactor * power at time of infraction amount := k.TokensFromConsensusPower(ctx, power) - slashAmountDec := amount.ToDec().Mul(slashFactor) + slashAmountDec := sdk.NewDecFromInt(amount).Mul(slashFactor) slashAmount := slashAmountDec.TruncateInt() // ref https://github.com/cosmos/cosmos-sdk/issues/1348 @@ -108,7 +108,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh // we need to calculate the *effective* slash fraction for distribution if validator.Tokens.IsPositive() { - effectiveFraction := tokensToBurn.ToDec().QuoRoundUp(validator.Tokens.ToDec()) + effectiveFraction := sdk.NewDecFromInt(tokensToBurn).QuoRoundUp(sdk.NewDecFromInt(validator.Tokens)) // possible if power has changed if effectiveFraction.GT(sdk.OneDec()) { effectiveFraction = sdk.OneDec() diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index c4109a9f3ddf..585897ca7929 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -196,7 +196,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) { // validator and next in line cliff validator app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, nextCliffVal) shares := app.StakingKeeper.TokensFromConsensusPower(ctx, 21) - nextCliffVal, _ = nextCliffVal.RemoveDelShares(shares.ToDec()) + nextCliffVal, _ = nextCliffVal.RemoveDelShares(sdk.NewDecFromInt(shares)) nextCliffVal = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, nextCliffVal, true) expectedValStatus := map[int]types.BondStatus{ @@ -300,7 +300,7 @@ func TestValidatorBasics(t *testing.T) { // modify a records, save, and retrieve validators[0].Status = types.Bonded validators[0].Tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - validators[0].DelegatorShares = validators[0].Tokens.ToDec() + validators[0].DelegatorShares = sdk.NewDecFromInt(validators[0].Tokens) validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], true) resVal, found = app.StakingKeeper.GetValidator(ctx, addrVals[0]) require.True(t, found) @@ -881,8 +881,8 @@ func TestApplyAndReturnValidatorSetUpdatesPowerDecrease(t *testing.T) { // tendermintUpdate set: {c1, c3} -> {c1', c3'} delTokens1 := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) delTokens2 := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) - validators[0], _ = validators[0].RemoveDelShares(delTokens1.ToDec()) - validators[1], _ = validators[1].RemoveDelShares(delTokens2.ToDec()) + validators[0], _ = validators[0].RemoveDelShares(sdk.NewDecFromInt(delTokens1)) + validators[1], _ = validators[1].RemoveDelShares(sdk.NewDecFromInt(delTokens2)) validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], false) validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], false) @@ -950,7 +950,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { app.StakingKeeper.SetValidator(ctx, validator) - validator, _ = validator.RemoveDelShares(amt.ToDec()) + validator, _ = validator.RemoveDelShares(sdk.NewDecFromInt(amt)) app.StakingKeeper.SetValidator(ctx, validator) app.StakingKeeper.SetValidatorByPowerIndex(ctx, validator) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 79bd2a4f55b1..88efb213f3ff 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -342,7 +342,7 @@ func (v Validator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error) { return sdk.ZeroDec(), ErrInsufficientShares } - return v.GetDelegatorShares().MulInt(amt).QuoTruncate(v.GetTokens().ToDec()), nil + return v.GetDelegatorShares().MulInt(amt).QuoTruncate(sdk.NewDecFromInt(v.GetTokens())), nil } // get the bonded tokens which the validator holds @@ -382,7 +382,7 @@ func (v Validator) AddTokensFromDel(amount sdk.Int) (Validator, sdk.Dec) { var issuedShares sdk.Dec if v.DelegatorShares.IsZero() { // the first delegation to a validator sets the exchange rate to one - issuedShares = amount.ToDec() + issuedShares = sdk.NewDecFromInt(amount) } else { shares, err := v.SharesFromTokens(amount) if err != nil { From 9fbd8f72a8fa1cd417a03da59a6e265f1b390299 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Apr 2022 18:17:48 -0400 Subject: [PATCH 20/22] updates --- x/staking/keeper/querier_test.go | 11 +++++------ x/staking/keeper/slash_test.go | 17 +++++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index f50e95a1833e..ac5b1eed5a56 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -351,7 +351,7 @@ func TestQueryDelegation(t *testing.T) { // Query unbonding delegation unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc2, val1.GetOperator(), unbondingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc2, val1.GetOperator(), sdk.NewDecFromInt(unbondingTokens)) require.NoError(t, err) queryBondParams = types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal1.String()} @@ -404,8 +404,7 @@ func TestQueryDelegation(t *testing.T) { // Query redelegation redelegationTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), - val2.GetOperator(), redelegationTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(redelegationTokens)) require.NoError(t, err) redel, found := app.StakingKeeper.GetRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator()) require.True(t, found) @@ -509,7 +508,7 @@ func TestQueryValidatorDelegations_Pagination(t *testing.T) { // Undelegate for _, addr := range addrs { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err := app.StakingKeeper.Undelegate(ctx, addr, val1.GetOperator(), delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addr, val1.GetOperator(), sdk.NewDecFromInt(delTokens)) require.NoError(t, err) } @@ -559,7 +558,7 @@ func TestQueryRedelegations(t *testing.T) { applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) rdAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), rdAmount.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount)) require.NoError(t, err) applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) @@ -631,7 +630,7 @@ func TestQueryUnbondingDelegation(t *testing.T) { // undelegate undelAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), undelAmount.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount)) require.NoError(t, err) applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 014173d9d075..ea83aab9dce2 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -390,12 +390,11 @@ func TestSlashWithRedelegation(t *testing.T) { // set a redelegation rdTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, - time.Unix(0, 0), rdTokens, rdTokens.ToDec()) + rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdTokens, sdk.NewDecFromInt(rdTokens)) app.StakingKeeper.SetRedelegation(ctx, rd) // set the associated delegation - del := types.NewDelegation(addrDels[0], addrVals[1], rdTokens.ToDec()) + del := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdTokens)) app.StakingKeeper.SetDelegation(ctx, del) // update bonded tokens @@ -416,7 +415,7 @@ func TestSlashWithRedelegation(t *testing.T) { require.True(t, found) require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction) }) - burnAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(fraction).TruncateInt() + burnAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt() bondedPool = app.StakingKeeper.GetBondedPool(ctx) notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) @@ -482,7 +481,7 @@ func TestSlashWithRedelegation(t *testing.T) { require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, sdk.OneDec()) }) - burnAmount = app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(sdk.OneDec()).TruncateInt() + burnAmount = sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(sdk.OneDec()).TruncateInt() burnAmount = burnAmount.Sub(sdk.OneDec().MulInt(rdTokens).TruncateInt()) // read updated pool @@ -543,13 +542,11 @@ func TestSlashBoth(t *testing.T) { // set a redelegation with expiration timestamp beyond which the // redelegation shouldn't be slashed rdATokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, - time.Unix(0, 0), rdATokens, - rdATokens.ToDec()) + rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdATokens, sdk.NewDecFromInt(rdATokens)) app.StakingKeeper.SetRedelegation(ctx, rdA) // set the associated delegation - delA := types.NewDelegation(addrDels[0], addrVals[1], rdATokens.ToDec()) + delA := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdATokens)) app.StakingKeeper.SetDelegation(ctx, delA) // set an unbonding delegation with expiration timestamp (beyond which the @@ -582,7 +579,7 @@ func TestSlashBoth(t *testing.T) { app.StakingKeeper.Slash(ctx, consAddr0, 10, 10, fraction) burnedNotBondedAmount := fraction.MulInt(ubdATokens).TruncateInt() - burnedBondAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(fraction).TruncateInt() + burnedBondAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt() burnedBondAmount = burnedBondAmount.Sub(burnedNotBondedAmount) // read updated pool From d0bd3e978620687ea9a82b491befd8d610a99f39 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 28 Apr 2022 08:39:11 -0400 Subject: [PATCH 21/22] updates --- contrib/images/simd-dlv/Dockerfile | 4 ++++ contrib/images/simd-env/Dockerfile | 3 +++ 2 files changed, 7 insertions(+) diff --git a/contrib/images/simd-dlv/Dockerfile b/contrib/images/simd-dlv/Dockerfile index 30ed840fcb63..e88fc4da0d9e 100644 --- a/contrib/images/simd-dlv/Dockerfile +++ b/contrib/images/simd-dlv/Dockerfile @@ -2,9 +2,13 @@ FROM golang:1.18-alpine AS build RUN apk add build-base git linux-headers libc-dev RUN go install github.com/go-delve/delve/cmd/dlv@latest + WORKDIR /work COPY go.mod go.sum /work/ COPY db/go.mod db/go.sum /work/db/ +COPY errors/go.mod errors/go.sum /work/errors/ +COPY math/go.mod math/go.sum /work/math/ + RUN go mod download COPY ./ /work RUN LEDGER_ENABLED=false make COSMOS_BUILD_OPTIONS="debug,nostrip" clean build diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index d32fdfe82614..0d3565375837 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -1,9 +1,12 @@ FROM golang:1.18-alpine AS build + RUN apk add build-base git linux-headers + WORKDIR /work COPY go.mod go.sum /work/ COPY db/go.mod db/go.sum /work/db/ COPY errors/go.mod errors/go.sum /work/errors/ +COPY math/go.mod math/go.sum /work/math/ RUN go mod download COPY ./ /work From 9e5a0d7862486368eeebdf20b9364081e9302959 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 28 Apr 2022 09:14:22 -0400 Subject: [PATCH 22/22] updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b6d7b003e0..b6a03be6098e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* (types) [#11788](https://github.com/cosmos/cosmos-sdk/pull/11788) The `Int` and `Uint` types have been moved to their own dedicated module, `math`. Aliases are kept in the SDK's root `types` package, however, it is encouraged to utilize the new `math` module. As a result, the `Int#ToDec` API has been removed. * (grpc) [\#11642](https://github.com/cosmos/cosmos-sdk/pull/11642) The `RegisterTendermintService` method in the `tmservice` package now requires a `abciQueryFn` query function parameter. * [\#11496](https://github.com/cosmos/cosmos-sdk/pull/11496) Refactor abstractions for snapshot and pruning; snapshot intervals eventually pruned; unit tests. * (types) [\#11689](https://github.com/cosmos/cosmos-sdk/pull/11689) Make `Coins#Sub` and `Coins#SafeSub` consistent with `Coins#Add`.