Skip to content

Commit

Permalink
Merge branch 'main' into julien/refactor-leveldb
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Sep 25, 2022
2 parents a989c26 + 55373cb commit bf08f48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions math/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

* [#13381](https://github.com/cosmos/cosmos-sdk/pull/13381) Add uint `IsNil` method.
* [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package, call it `LegacyDec`.
5 changes: 5 additions & 0 deletions math/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func (u Uint) BigInt() *big.Int {
return new(big.Int).Set(u.i)
}

// IsNil returns true if Uint is uninitialized
func (u Uint) IsNil() bool {
return u.i == nil
}

// NewUintFromBigUint constructs Uint from big.Uint
func NewUintFromBigInt(i *big.Int) Uint {
u, err := checkNewUint(i)
Expand Down
5 changes: 5 additions & 0 deletions math/uint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func (s *uintTestSuite) TestUintPanics() {
s.Require().True(sdkmath.ZeroUint().LTE(sdkmath.OneUint()))
}

func (s *uintTestSuite) TestIsNil() {
s.Require().False(sdkmath.OneUint().IsNil())
s.Require().True(sdkmath.Uint{}.IsNil())
}

func (s *uintTestSuite) TestArithUint() {
for d := 0; d < 1000; d++ {
n1 := uint64(rand.Uint32())
Expand Down

0 comments on commit bf08f48

Please sign in to comment.