-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(x/accounts/default/lockup): Lockup account track undelegation when unbonding entry is mature #22254
fix(x/accounts/default/lockup): Lockup account track undelegation when unbonding entry is mature #22254
Changes from 36 commits
4fd342f
83d300d
41a1808
a63f909
0544b0d
a37205e
e1e0ce2
b1135b6
716621a
7641b26
700ea01
0c26ac3
2eaff98
8ff7f82
f157e17
de6f925
075d9ee
9f25810
22d24c1
c990e46
8e9bde2
70e61c5
4158151
e0b096e
7e5d20e
2a8d551
4e83bc7
646c178
f9dcc39
f9d1bfb
8e3be3d
7fb8c29
ed0cbdb
1ed4b64
a7ee203
af32a94
54c8f5c
a4c8c3e
292cf01
ce829cf
be528f7
5f59218
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,44 +101,21 @@ func TestDelayedAccountUndelegate(t *testing.T) { | |
}) | ||
require.NoError(t, err) | ||
|
||
delLocking, err = acc.DelegatedLocking.Get(ctx, "test") | ||
entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address") | ||
require.NoError(t, err) | ||
require.True(t, delLocking.Equal(math.ZeroInt())) | ||
require.Len(t, entries.Entries, 1) | ||
require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1))) | ||
require.True(t, entries.Entries[0].ValidatorAddress == "val_address") | ||
|
||
endTime, err := acc.EndTime.Get(sdkCtx) | ||
err = acc.CheckUbdEntriesMature(sdkCtx) | ||
require.NoError(t, err) | ||
|
||
// Update context time to unlocked all the original locking amount | ||
sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ | ||
Time: endTime.Add(time.Second), | ||
}) | ||
|
||
_, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{ | ||
Sender: "owner", | ||
ValidatorAddress: "val_address", | ||
Amount: sdk.NewCoin("test", math.NewInt(6)), | ||
}) | ||
require.NoError(t, err) | ||
_, err = acc.UnbondEntries.Get(sdkCtx, "val_address") | ||
require.Error(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add timeline validation for unbonding process. The test should verify the intermediate state during the unbonding period. Add assertions to check:
err = acc.CheckUbdEntriesMature(sdkCtx)
require.NoError(t, err)
+
+// Verify intermediate state
+delLocking, err = acc.DelegatedLocking.Get(ctx, "test")
+require.NoError(t, err)
+require.True(t, delLocking.Equal(math.NewInt(1))) // Should still be locked
+
+// Advance time to maturity
+sdkCtx = sdkCtx.WithHeaderInfo(header.Info{
+ Time: entries.Entries[0].CompletionTime,
+})
+
+err = acc.CheckUbdEntriesMature(sdkCtx)
+require.NoError(t, err)
|
||
|
||
delLocking, err = acc.DelegatedLocking.Get(ctx, "test") | ||
require.NoError(t, err) | ||
require.True(t, delLocking.Equal(math.ZeroInt())) | ||
|
||
delFree, err := acc.DelegatedFree.Get(ctx, "test") | ||
require.NoError(t, err) | ||
require.True(t, delFree.Equal(math.NewInt(6))) | ||
|
||
// Undelegate | ||
_, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{ | ||
Sender: "owner", | ||
ValidatorAddress: "val_address", | ||
Amount: sdk.NewCoin("test", math.NewInt(4)), | ||
}) | ||
require.NoError(t, err) | ||
|
||
delFree, err = acc.DelegatedFree.Get(ctx, "test") | ||
require.NoError(t, err) | ||
require.True(t, delFree.Equal(math.NewInt(2))) | ||
} | ||
|
||
func TestDelayedAccountSendCoins(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add timeline validation for undelegation process
The test should verify the intermediate state where funds are still locked during the unbonding period. Add assertions to check:
Example: