-
Notifications
You must be signed in to change notification settings - Fork 607
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
feat: partial superfluid undelegate #5162
Changes from 17 commits
61e3741
ac83d9f
b72ea48
ec3672d
749b82d
d783cd5
c7fd2bb
eb8b67d
2a619ad
03b1074
0d1e2c5
d71ad69
a7cd212
c20dded
91911c8
efb468c
2c96b6d
1aa1f05
ff187c6
9a91185
83e6725
ead576b
ad73380
d596854
38ae310
5ecec51
dfe204b
c59c387
d1c7b6f
315e8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -533,6 +533,60 @@ func (suite *KeeperTestSuite) TestCreateLock() { | |
suite.Require().Equal(sdk.NewInt(30), balance.Amount) | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestCreateLockNoSend() { | ||
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. Is there a particular reason you made these non table driven? 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. Yes, the pre-existing |
||
suite.SetupTest() | ||
|
||
addr1 := sdk.AccAddress([]byte("addr1---------------")) | ||
coins := sdk.Coins{sdk.NewInt64Coin("stake", 10)} | ||
|
||
// test locking without balance | ||
lock, err := suite.App.LockupKeeper.CreateLockNoSend(suite.Ctx, addr1, coins, time.Second) | ||
suite.Require().NoError(err) | ||
|
||
// check new lock | ||
suite.Require().Equal(coins, lock.Coins) | ||
suite.Require().Equal(time.Second, lock.Duration) | ||
suite.Require().Equal(time.Time{}, lock.EndTime) | ||
suite.Require().Equal(uint64(1), lock.ID) | ||
|
||
lockID := suite.App.LockupKeeper.GetLastLockID(suite.Ctx) | ||
suite.Require().Equal(uint64(1), lockID) | ||
|
||
// check accumulation store | ||
accum := suite.App.LockupKeeper.GetPeriodLocksAccumulation(suite.Ctx, types.QueryCondition{ | ||
LockQueryType: types.ByDuration, | ||
Denom: "stake", | ||
Duration: time.Second, | ||
}) | ||
suite.Require().Equal(accum.String(), "10") | ||
|
||
// create new lock (this time with a balance) | ||
coins = sdk.Coins{sdk.NewInt64Coin("stake", 20)} | ||
p0mvn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
suite.FundAcc(addr1, coins) | ||
|
||
lock, err = suite.App.LockupKeeper.CreateLockNoSend(suite.Ctx, addr1, coins, time.Second) | ||
suite.Require().NoError(err) | ||
|
||
lockID = suite.App.LockupKeeper.GetLastLockID(suite.Ctx) | ||
suite.Require().Equal(uint64(2), lockID) | ||
|
||
// check accumulation store | ||
accum = suite.App.LockupKeeper.GetPeriodLocksAccumulation(suite.Ctx, types.QueryCondition{ | ||
LockQueryType: types.ByDuration, | ||
Denom: "stake", | ||
Duration: time.Second, | ||
}) | ||
suite.Require().Equal(accum.String(), "30") | ||
|
||
// check balance | ||
p0mvn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
balance := suite.App.BankKeeper.GetBalance(suite.Ctx, addr1, "stake") | ||
suite.Require().Equal(sdk.NewInt(20).String(), balance.Amount.String()) | ||
p0mvn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
acc := suite.App.AccountKeeper.GetModuleAccount(suite.Ctx, types.ModuleName) | ||
balance = suite.App.BankKeeper.GetBalance(suite.Ctx, acc.GetAddress(), "stake") | ||
suite.Require().Equal(sdk.ZeroInt().String(), balance.Amount.String()) | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestAddTokensToLock() { | ||
initialLockCoin := sdk.NewInt64Coin("stake", 10) | ||
addr1 := sdk.AccAddress([]byte("addr1---------------")) | ||
|
@@ -703,7 +757,7 @@ func (suite *KeeperTestSuite) TestHasLock() { | |
} | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestLock() { | ||
func (suite *KeeperTestSuite) TestLockNoSend() { | ||
suite.SetupTest() | ||
|
||
addr1 := sdk.AccAddress([]byte("addr1---------------")) | ||
|
@@ -717,20 +771,20 @@ func (suite *KeeperTestSuite) TestLock() { | |
Coins: coins, | ||
} | ||
|
||
// test locking without balance | ||
err := suite.App.LockupKeeper.Lock(suite.Ctx, lock, coins) | ||
suite.Require().Error(err) | ||
// test locking without balance (should work since we don't send the underlying balance) | ||
err := suite.App.LockupKeeper.LockNoSend(suite.Ctx, lock, coins) | ||
suite.Require().NoError(err) | ||
|
||
// check accumulation store | ||
accum := suite.App.LockupKeeper.GetPeriodLocksAccumulation(suite.Ctx, types.QueryCondition{ | ||
LockQueryType: types.ByDuration, | ||
Denom: "stake", | ||
Duration: time.Second, | ||
}) | ||
suite.Require().Equal(accum.String(), "0") | ||
suite.Require().Equal(accum.String(), "10") | ||
|
||
suite.FundAcc(addr1, coins) | ||
err = suite.App.LockupKeeper.Lock(suite.Ctx, lock, coins) | ||
err = suite.App.LockupKeeper.LockNoSend(suite.Ctx, lock, coins) | ||
suite.Require().NoError(err) | ||
|
||
// check accumulation store | ||
|
@@ -739,14 +793,15 @@ func (suite *KeeperTestSuite) TestLock() { | |
Denom: "stake", | ||
Duration: time.Second, | ||
}) | ||
suite.Require().Equal(accum.String(), "10") | ||
suite.Require().Equal(accum.String(), "20") | ||
|
||
// Since lockNoSend does not send the underlying coins, the account balance should be unchanged | ||
balance := suite.App.BankKeeper.GetBalance(suite.Ctx, addr1, "stake") | ||
suite.Require().Equal(sdk.ZeroInt(), balance.Amount) | ||
suite.Require().Equal(sdk.NewInt(10).String(), balance.Amount.String()) | ||
|
||
acc := suite.App.AccountKeeper.GetModuleAccount(suite.Ctx, types.ModuleName) | ||
balance = suite.App.BankKeeper.GetBalance(suite.Ctx, acc.GetAddress(), "stake") | ||
suite.Require().Equal(sdk.NewInt(10), balance.Amount) | ||
suite.Require().Equal(sdk.NewInt(0).String(), balance.Amount.String()) | ||
} | ||
|
||
func (suite *KeeperTestSuite) AddTokensToLockForSynth() { | ||
|
@@ -1272,6 +1327,7 @@ func (suite *KeeperTestSuite) TestPartialForceUnlock() { | |
|
||
defaultDenomToLock := "stake" | ||
defaultAmountToLock := sdk.NewInt(10000000) | ||
coinsToLock := sdk.NewCoins(sdk.NewCoin("stake", defaultAmountToLock)) | ||
|
||
testCases := []struct { | ||
name string | ||
|
@@ -1280,7 +1336,7 @@ func (suite *KeeperTestSuite) TestPartialForceUnlock() { | |
}{ | ||
{ | ||
name: "unlock full amount", | ||
coinsToForceUnlock: sdk.Coins{sdk.NewCoin(defaultDenomToLock, defaultAmountToLock)}, | ||
coinsToForceUnlock: coinsToLock, | ||
expectedPass: true, | ||
}, | ||
{ | ||
|
@@ -1302,9 +1358,9 @@ func (suite *KeeperTestSuite) TestPartialForceUnlock() { | |
for _, tc := range testCases { | ||
// set up test and create default lock | ||
suite.SetupTest() | ||
coinsToLock := sdk.NewCoins(sdk.NewCoin("stake", defaultAmountToLock)) | ||
|
||
suite.FundAcc(addr1, sdk.NewCoins(coinsToLock...)) | ||
// balanceBeforeLock := suite.App.BankKeeper.GetAllBalances(suite.Ctx, addr1) | ||
|
||
lock, err := suite.App.LockupKeeper.CreateLock(suite.Ctx, addr1, coinsToLock, time.Minute) | ||
suite.Require().NoError(err) | ||
|
||
|
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.
Can you elaborate in the comment why this is needed? That is why we have
CreateLockNoSend
andCreateLock
. I would also copy this context intoCreateLock
godocThere 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.
Comment expanded here c59c387