Skip to content

Commit

Permalink
fix: adding checks to ensure coin denoms are sorted in Balance duri…
Browse files Browse the repository at this point in the history
…ng `Validate` (backport cosmos#9829) (cosmos#10849)

* adding checks to ensure denoms are sorted

(cherry picked from commit ce1e650)

* updating changelog

(cherry picked from commit 2cea5e5)

# Conflicts:
#	CHANGELOG.md

* refactoring balance.coin validation

(cherry picked from commit 40d22c7)

* adding 0 value coin test case

(cherry picked from commit 2468b64)

* added valid sorted coin testcase

(cherry picked from commit 66b91ee)

* updating changelog

(cherry picked from commit 59b788a)

# Conflicts:
#	CHANGELOG.md

* conflicts

Co-authored-by: Spoorthi <9302666+spoo-bar@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 47ada40 commit 4e49c47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) - 2021-12-07

### State Machine Breaking

* (auth) [\#10536](https://github.com/cosmos/cosmos-sdk/pull/10536]) Enable `SetSequence` for `ModuleAccount`.
Expand All @@ -63,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt`.
* [#10725](https://github.com/cosmos/cosmos-sdk/pull/10725) populate `ctx.ConsensusParams` for begin/end blockers.
* [\#9829](https://github.com/cosmos/cosmos-sdk/pull/9829) Fixed Coin denom sorting not being checked during `Balance.Validate` check. Refactored the Validation logic to use `Coins.Validate` for `Balance.Coins`

## [v0.44.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.5) - 2021-12-02

Expand Down
23 changes: 23 additions & 0 deletions x/bank/types/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ func TestBalanceValidate(t *testing.T) {
},
true,
},
{
"0 value coin",
bank.Balance{
Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t",
Coins: sdk.Coins{
sdk.NewInt64Coin("atom", 0),
sdk.NewInt64Coin("zatom", 2),
},
},
true,
},
{
"unsorted coins",
bank.Balance{
Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t",
Coins: sdk.Coins{
sdk.NewInt64Coin("atom", 2),
sdk.NewInt64Coin("zatom", 2),
sdk.NewInt64Coin("batom", 12),
},
},
true,
},
{
"valid sorted coins",
bank.Balance{
Expand Down

0 comments on commit 4e49c47

Please sign in to comment.