8
8
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
9
9
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
10
10
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
11
+ stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
11
12
"github.com/ethereum/go-ethereum/common"
12
13
"github.com/ethereum/go-ethereum/crypto"
13
14
"github.com/haqq-network/haqq/contracts"
@@ -76,6 +77,22 @@ func (suite *KeeperTestSuite) TestLiquidate() {
76
77
amount : sdk .NewCoin ("aISLM" , amount .AmountOf ("aISLM" )),
77
78
expectPass : true ,
78
79
},
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
+ },
79
96
{
80
97
name : "fail - liquidate amount bigger than locked but less than total" ,
81
98
malleate : func () {
@@ -92,6 +109,22 @@ func (suite *KeeperTestSuite) TestLiquidate() {
92
109
amount : sdk .NewCoin ("aISLM" , amount .AmountOf ("aISLM" ).Add (math .NewInt (1_500_000 ))),
93
110
expectPass : false ,
94
111
},
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
+ },
95
128
{
96
129
name : "fail - liquidate tokens partially unlocked" ,
97
130
malleate : func () {
0 commit comments