Skip to content

Commit 03bba90

Browse files
ivanovpetrPetr Ivanov
and
Petr Ivanov
authored
Add tests for liquidation staked tokens (#299)
* add tests for liquidation staked tokens * change test description --------- Co-authored-by: Petr Ivanov <[email protected]>
1 parent bd24b5b commit 03bba90

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Diff for: x/liquidvesting/keeper/msg_server_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
99
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
1010
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
11+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1112
"github.com/ethereum/go-ethereum/common"
1213
"github.com/ethereum/go-ethereum/crypto"
1314
"github.com/haqq-network/haqq/contracts"
@@ -76,6 +77,22 @@ func (suite *KeeperTestSuite) TestLiquidate() {
7677
amount: sdk.NewCoin("aISLM", amount.AmountOf("aISLM")),
7778
expectPass: true,
7879
},
80+
{
81+
name: "ok - liquidate partially staked tokens",
82+
malleate: func() {
83+
funder := sdk.AccAddress(types.ModuleName)
84+
baseAccount := authtypes.NewBaseAccountWithAddress(addr1)
85+
startTime := suite.ctx.BlockTime().Add(-10 * time.Second)
86+
clawbackAccount := vestingtypes.NewClawbackVestingAccount(baseAccount, funder, amount, startTime, lockupPeriods, vestingPeriods, nil)
87+
testutil.FundAccount(s.ctx, s.app.BankKeeper, addr1, amount) //nolint:errcheck
88+
s.app.AccountKeeper.SetAccount(s.ctx, clawbackAccount)
89+
s.app.StakingKeeper.Delegate(s.ctx, addr1, third.AmountOf("aISLM"), stakingtypes.Unbonded, s.validator, true) //nolint:errcheck
90+
},
91+
from: addr1,
92+
to: addr2,
93+
amount: sdk.NewCoin("aISLM", third.AmountOf("aISLM").Add(third.AmountOf("aISLM"))),
94+
expectPass: true,
95+
},
7996
{
8097
name: "fail - liquidate amount bigger than locked but less than total",
8198
malleate: func() {
@@ -92,6 +109,22 @@ func (suite *KeeperTestSuite) TestLiquidate() {
92109
amount: sdk.NewCoin("aISLM", amount.AmountOf("aISLM").Add(math.NewInt(1_500_000))),
93110
expectPass: false,
94111
},
112+
{
113+
name: "fail - liquidate staked tokens",
114+
malleate: func() {
115+
funder := sdk.AccAddress(types.ModuleName)
116+
baseAccount := authtypes.NewBaseAccountWithAddress(addr1)
117+
startTime := suite.ctx.BlockTime().Add(-10 * time.Second)
118+
clawbackAccount := vestingtypes.NewClawbackVestingAccount(baseAccount, funder, amount, startTime, lockupPeriods, vestingPeriods, nil)
119+
testutil.FundAccount(s.ctx, s.app.BankKeeper, addr1, amount) //nolint:errcheck
120+
s.app.AccountKeeper.SetAccount(s.ctx, clawbackAccount)
121+
s.app.StakingKeeper.Delegate(s.ctx, addr1, amount.AmountOf("aISLM"), stakingtypes.Unbonded, s.validator, true) //nolint:errcheck
122+
},
123+
from: addr1,
124+
to: addr2,
125+
amount: sdk.NewCoin("aISLM", amount.AmountOf("aISLM")),
126+
expectPass: false,
127+
},
95128
{
96129
name: "fail - liquidate tokens partially unlocked",
97130
malleate: func() {

0 commit comments

Comments
 (0)