Skip to content

Commit

Permalink
updates tesst
Browse files Browse the repository at this point in the history
  • Loading branch information
DongLieu committed Jan 22, 2025
1 parent fe3e263 commit 0f6b62d
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions x/vaults/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,30 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
expPass bool
}{
{
name: "success, shortfallAmount is less than reserve balances",
name: "success burn part",
mintDenom: "fxUSD",
setup: func() types.MsgBurnShortfall {
// make sure reserve has money
mintCoin := sdk.NewCoins(sdk.NewCoin("fxUSD", math.NewInt(10_000_000)))
s.FundAccount(s.TestAccs[0], types.ModuleName, mintCoin)
err := s.k.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, s.TestAccs[0], types.ReserveModuleName, mintCoin)
s.Require().NoError(err)

// make sure Guaranteed Shortfall Amount
err = s.k.ShortfallAmount.Set(s.Ctx, "fxUSD", math.NewInt(5_000_000))
s.Require().NoError(err)
return types.MsgBurnShortfall{
Authority: "onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k",
MintDenom: "fxUSD",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.NewInt(4_000_000),
expReserveBalcesAfterBurn: math.NewInt(9_000_000),
expPass: true,
},
{
name: "success maximum burn, shortfallAmount is less than reserve balances",
mintDenom: "fxUSD",
setup: func() types.MsgBurnShortfall {
// make sure reserve has money
Expand All @@ -33,14 +56,15 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
return types.MsgBurnShortfall{
Authority: "onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k",
MintDenom: "fxUSD",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.ZeroInt(),
expReserveBalcesAfterBurn: math.NewInt(9_000_000),
expPass: true,
},
{
name: "success, reserve balancess is less than shortfallAmount",
name: "success maximum burn, reserve balancess is less than shortfallAmount",
mintDenom: "fxUSD",
setup: func() types.MsgBurnShortfall {
// make sure reserve has money
Expand All @@ -55,14 +79,15 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
return types.MsgBurnShortfall{
Authority: "onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k",
MintDenom: "fxUSD",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.NewInt(9_000_000),
expReserveBalcesAfterBurn: math.ZeroInt(),
expPass: true,
},
{
name: "success, reserve balancess no money",
name: "fail, reserve balancess no money",
mintDenom: "fxUSD",
setup: func() types.MsgBurnShortfall {
// make sure Guaranteed Shortfall Amount
Expand All @@ -71,11 +96,10 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
return types.MsgBurnShortfall{
Authority: "onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k",
MintDenom: "fxUSD",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.NewInt(10_000_000),
expReserveBalcesAfterBurn: math.ZeroInt(),
expPass: true,
expPass: false,
},
{
name: "fail, government account not the signatory for the proposed message",
Expand All @@ -93,11 +117,10 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
return types.MsgBurnShortfall{
Authority: s.TestAccs[0].String(),
MintDenom: "fxUSD",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.NewInt(9_000_000),
expReserveBalcesAfterBurn: math.ZeroInt(),
expPass: false,
expPass: false,
},
{
name: "fail, denom is not in the allowed mint denom list",
Expand All @@ -115,11 +138,31 @@ func (s *KeeperTestSuite) TestBurnShortfallByMintDenom() {
return types.MsgBurnShortfall{
Authority: s.TestAccs[0].String(),
MintDenom: "atom",
Amount: math.NewInt(1_000_000),
}
},
expShortfallAmountAfterBurn: math.NewInt(9_000_000),
expReserveBalcesAfterBurn: math.ZeroInt(),
expPass: false,
expPass: false,
},
{
name: "fail, burn all",
mintDenom: "fxUSD",
setup: func() types.MsgBurnShortfall {
// make sure reserve has money
mintCoin := sdk.NewCoins(sdk.NewCoin("fxUSD", math.NewInt(5_000_000)))
s.FundAccount(s.TestAccs[0], types.ModuleName, mintCoin)
err := s.k.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, s.TestAccs[0], types.ReserveModuleName, mintCoin)
s.Require().NoError(err)

// make sure Guaranteed Shortfall Amount
err = s.k.ShortfallAmount.Set(s.Ctx, "fxUSD", math.NewInt(5_000_000))
s.Require().NoError(err)
return types.MsgBurnShortfall{
Authority: "onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k",
MintDenom: "fxUSD",
Amount: math.NewInt(10_000_000),
}
},
expPass: false,
},
}

Expand Down

0 comments on commit 0f6b62d

Please sign in to comment.