Skip to content

Commit

Permalink
fix 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki committed Sep 15, 2023
1 parent b96b879 commit aaaf5e3
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 3 deletions.
7 changes: 4 additions & 3 deletions x/leverage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,10 @@ func (s msgServer) GovUpdateSpecialAssets(
for _, b := range set.Assets {
if a != b {
pair := types.SpecialAssetPair{
Collateral: a,
Borrow: b,
CollateralWeight: set.CollateralWeight,
Collateral: a,
Borrow: b,
CollateralWeight: set.CollateralWeight,
LiquidationThreshold: set.LiquidationThreshold,
}
// sets or overrides (or deletes on zero collateral weight) each pair
if err := s.keeper.SetSpecialAssetPair(ctx, pair); err != nil {
Expand Down
96 changes: 96 additions & 0 deletions x/leverage/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,102 @@ func (s *IntegrationTestSuite) TestUpdateRegistry() {
}
}

func (s *IntegrationTestSuite) TestUpdateSpecialAssets() {
govAccAddr := checkers.GovModuleAddr

testCases := []struct {
name string
req *types.MsgGovUpdateSpecialAssets
expectErr bool
errMsg string
}{
{
"empty",
&types.MsgGovUpdateSpecialAssets{
Authority: govAccAddr,
Description: "test",
Sets: []types.SpecialAssetSet{},
Pairs: []types.SpecialAssetPair{},
},
true,
"empty",
},
{
"valid set",
&types.MsgGovUpdateSpecialAssets{
Authority: govAccAddr,
Description: "test",
Sets: []types.SpecialAssetSet{
{
Assets: []string{"test1", "test2"},
CollateralWeight: sdk.MustNewDecFromStr("0.8"),
LiquidationThreshold: sdk.MustNewDecFromStr("0.9"),
},
},
Pairs: []types.SpecialAssetPair{},
},
false,
"",
},
{
"valid pair",
&types.MsgGovUpdateSpecialAssets{
Authority: govAccAddr,
Description: "test",
Sets: []types.SpecialAssetSet{},
Pairs: []types.SpecialAssetPair{
{
Borrow: "test1",
Collateral: "test2",
CollateralWeight: sdk.MustNewDecFromStr("0.8"),
LiquidationThreshold: sdk.MustNewDecFromStr("0.9"),
},
},
},
false,
"",
},
{
"valid set and pair",
&types.MsgGovUpdateSpecialAssets{
Authority: govAccAddr,
Description: "test",
Sets: []types.SpecialAssetSet{
{
Assets: []string{"test1", "test2"},
CollateralWeight: sdk.MustNewDecFromStr("0.8"),
LiquidationThreshold: sdk.MustNewDecFromStr("0.9"),
},
},
Pairs: []types.SpecialAssetPair{
{
Borrow: "test1",
Collateral: "test2",
CollateralWeight: sdk.MustNewDecFromStr("0.8"),
LiquidationThreshold: sdk.MustNewDecFromStr("0.9"),
},
},
},
false,
"",
},
}

for _, tc := range testCases {
s.Run(tc.name, func() {
err := tc.req.ValidateBasic()
if err == nil {
_, err = s.msgSrvr.GovUpdateSpecialAssets(s.ctx, tc.req)
}
if tc.expectErr {
s.Require().ErrorContains(err, tc.errMsg)
} else {
s.Require().NoError(err)
}
})
}
}

func (s *IntegrationTestSuite) TestMsgSupply() {
type testCase struct {
msg string
Expand Down

0 comments on commit aaaf5e3

Please sign in to comment.