Skip to content

Commit

Permalink
fix: update redelegation stringer (#14064)
Browse files Browse the repository at this point in the history
* fix: update redelegation stringer

* updates

* space instead of tab

* Update x/staking/types/delegation.go

Co-authored-by: Facundo Medica <[email protected]>

* add changelog

Co-authored-by: Facundo Medica <[email protected]>
  • Loading branch information
julienrbrt and facundomedica authored Nov 29, 2022
1 parent 0d5a7f8 commit 33192dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (x/staking) [#14064](https://github.com/cosmos/cosmos-sdk/pull/14064) Set all fields in `redelegation.String()`.
* (x/upgrade) [#13936](https://github.com/cosmos/cosmos-sdk/pull/13936) Make downgrade verification work again.
* (x/group) [#13742](https://github.com/cosmos/cosmos-sdk/pull/13742) Fix `validate-genesis` when group policy accounts exist.
* (baseapp) [#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero.
Expand Down
10 changes: 6 additions & 4 deletions x/staking/types/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,13 @@ func (red Redelegation) String() string {

for i, entry := range red.Entries {
out += fmt.Sprintf(` Redelegation Entry #%d:
Creation height: %v
Min time to unbond (unix): %v
Dest Shares: %s
Creation height: %v
Min time to unbond (unix): %v
Dest Shares: %s
Unbonding ID: %d
Unbonding Ref Count: %d
`,
i, entry.CreationHeight, entry.CompletionTime, entry.SharesDst,
i, entry.CreationHeight, entry.CompletionTime, entry.SharesDst, entry.UnbondingId, entry.UnbondingOnHoldRefCount,
)
}

Expand Down
12 changes: 6 additions & 6 deletions x/staking/types/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ func TestRedelegationEqual(t *testing.T) {
r2 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0,
time.Unix(0, 0), sdk.NewInt(0),
math.LegacyNewDec(0), 2)

ok := r1.String() == r2.String()
require.True(t, ok)
require.False(t, r1.String() == r2.String())
r2 = types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0,
time.Unix(0, 0), sdk.NewInt(0),
math.LegacyNewDec(0), 1)
require.True(t, r1.String() == r2.String())

r2.Entries[0].SharesDst = math.LegacyNewDec(10)
r2.Entries[0].CompletionTime = time.Unix(20*20*2, 0)

ok = r1.String() == r2.String()
require.False(t, ok)
require.False(t, r1.String() == r2.String())
}

func TestRedelegationString(t *testing.T) {
Expand Down

0 comments on commit 33192dd

Please sign in to comment.