2020-09-21 21:08:43 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2023-04-05 23:21:59 +00:00
|
|
|
sdkmath "cosmossdk.io/math"
|
2024-02-06 22:54:10 +00:00
|
|
|
"github.com/cometbft/cometbft/crypto"
|
|
|
|
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
|
|
tmtime "github.com/cometbft/cometbft/types/time"
|
2020-09-21 21:08:43 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2024-08-03 09:51:56 +00:00
|
|
|
"github.com/0glabs/0g-chain/app"
|
|
|
|
"github.com/0glabs/0g-chain/x/hard"
|
|
|
|
"github.com/0glabs/0g-chain/x/hard/types"
|
|
|
|
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
|
2020-09-21 21:08:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (suite *KeeperTestSuite) TestDeposit() {
|
|
|
|
type args struct {
|
|
|
|
depositor sdk.AccAddress
|
2020-12-18 16:05:21 +00:00
|
|
|
amount sdk.Coins
|
2020-09-21 21:08:43 +00:00
|
|
|
numberDeposits int
|
|
|
|
expectedAccountBalance sdk.Coins
|
|
|
|
expectedModAccountBalance sdk.Coins
|
2020-12-18 16:05:21 +00:00
|
|
|
expectedDepositCoins sdk.Coins
|
2020-09-21 21:08:43 +00:00
|
|
|
}
|
|
|
|
type errArgs struct {
|
|
|
|
expectPass bool
|
|
|
|
contains string
|
|
|
|
}
|
|
|
|
type depositTest struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
errArgs errArgs
|
|
|
|
}
|
|
|
|
testCases := []depositTest{
|
|
|
|
{
|
|
|
|
"valid",
|
|
|
|
args{
|
|
|
|
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
2023-04-05 23:21:59 +00:00
|
|
|
amount: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(100))),
|
2020-09-21 21:08:43 +00:00
|
|
|
numberDeposits: 1,
|
2023-04-05 23:21:59 +00:00
|
|
|
expectedAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(900)), sdk.NewCoin("btcb", sdkmath.NewInt(1000))),
|
|
|
|
expectedModAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(100))),
|
|
|
|
expectedDepositCoins: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(100))),
|
2020-09-21 21:08:43 +00:00
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"valid multi deposit",
|
|
|
|
args{
|
|
|
|
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
2023-04-05 23:21:59 +00:00
|
|
|
amount: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(100))),
|
2020-09-21 21:08:43 +00:00
|
|
|
numberDeposits: 2,
|
2023-04-05 23:21:59 +00:00
|
|
|
expectedAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(800)), sdk.NewCoin("btcb", sdkmath.NewInt(1000))),
|
|
|
|
expectedModAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(200))),
|
|
|
|
expectedDepositCoins: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(200))),
|
2020-09-21 21:08:43 +00:00
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"invalid deposit denom",
|
|
|
|
args{
|
|
|
|
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
2023-04-05 23:21:59 +00:00
|
|
|
amount: sdk.NewCoins(sdk.NewCoin("fake", sdkmath.NewInt(100))),
|
2020-09-21 21:08:43 +00:00
|
|
|
numberDeposits: 1,
|
|
|
|
expectedAccountBalance: sdk.Coins{},
|
|
|
|
expectedModAccountBalance: sdk.Coins{},
|
2020-12-18 16:05:21 +00:00
|
|
|
expectedDepositCoins: sdk.Coins{},
|
2020-09-21 21:08:43 +00:00
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: false,
|
|
|
|
contains: "invalid deposit denom",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"insufficient funds",
|
|
|
|
args{
|
|
|
|
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
2023-04-05 23:21:59 +00:00
|
|
|
amount: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(10000))),
|
2020-09-21 21:08:43 +00:00
|
|
|
numberDeposits: 1,
|
|
|
|
expectedAccountBalance: sdk.Coins{},
|
|
|
|
expectedModAccountBalance: sdk.Coins{},
|
2020-12-18 16:05:21 +00:00
|
|
|
expectedDepositCoins: sdk.Coins{},
|
2020-09-21 21:08:43 +00:00
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: false,
|
2021-03-15 15:15:19 +00:00
|
|
|
contains: "insufficient funds: the requested deposit amount",
|
2020-09-21 21:08:43 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
|
|
suite.Run(tc.name, func() {
|
|
|
|
// create new app with one funded account
|
2020-10-05 21:44:17 +00:00
|
|
|
|
2020-09-21 21:08:43 +00:00
|
|
|
// Initialize test app and set context
|
|
|
|
tApp := app.NewTestApp()
|
2022-01-08 00:39:27 +00:00
|
|
|
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
|
|
|
authGS := app.NewFundedGenStateWithCoins(
|
|
|
|
tApp.AppCodec(),
|
|
|
|
[]sdk.Coins{
|
|
|
|
sdk.NewCoins(
|
2023-04-05 23:21:59 +00:00
|
|
|
sdk.NewCoin("bnb", sdkmath.NewInt(1000)),
|
|
|
|
sdk.NewCoin("btcb", sdkmath.NewInt(1000)),
|
2022-01-08 00:39:27 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
[]sdk.AccAddress{tc.args.depositor},
|
|
|
|
)
|
2020-10-30 09:59:47 +00:00
|
|
|
loanToValue, _ := sdk.NewDecFromStr("0.6")
|
2020-12-21 17:18:55 +00:00
|
|
|
hardGS := types.NewGenesisState(types.NewParams(
|
2020-10-30 09:59:47 +00:00
|
|
|
types.MoneyMarkets{
|
2023-04-05 23:21:59 +00:00
|
|
|
types.NewMoneyMarket("usdx", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "usdx:usd", sdkmath.NewInt(1000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
|
|
|
types.NewMoneyMarket("ukava", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "kava:usd", sdkmath.NewInt(1000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
|
|
|
types.NewMoneyMarket("bnb", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "bnb:usd", sdkmath.NewInt(1000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
|
|
|
types.NewMoneyMarket("btcb", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "btcb:usd", sdkmath.NewInt(1000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
2020-10-30 09:59:47 +00:00
|
|
|
},
|
2021-02-12 15:28:05 +00:00
|
|
|
sdk.NewDec(10),
|
2021-01-23 05:17:40 +00:00
|
|
|
), types.DefaultAccumulationTimes, types.DefaultDeposits, types.DefaultBorrows,
|
|
|
|
types.DefaultTotalSupplied, types.DefaultTotalBorrowed, types.DefaultTotalReserves,
|
|
|
|
)
|
2020-12-16 21:08:29 +00:00
|
|
|
|
|
|
|
// Pricefeed module genesis state
|
2022-01-08 00:39:27 +00:00
|
|
|
pricefeedGS := pricefeedtypes.GenesisState{
|
|
|
|
Params: pricefeedtypes.Params{
|
|
|
|
Markets: []pricefeedtypes.Market{
|
2020-12-16 21:08:29 +00:00
|
|
|
{MarketID: "usdx:usd", BaseAsset: "usdx", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "kava:usd", BaseAsset: "kava", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "btcb:usd", BaseAsset: "btcb", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "bnb:usd", BaseAsset: "bnb", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
},
|
|
|
|
},
|
2022-01-08 00:39:27 +00:00
|
|
|
PostedPrices: []pricefeedtypes.PostedPrice{
|
2020-12-16 21:08:29 +00:00
|
|
|
{
|
|
|
|
MarketID: "usdx:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("1.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MarketID: "kava:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("2.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MarketID: "btcb:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("100.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MarketID: "bnb:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("10.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
tApp.InitializeFromGenesisStates(authGS,
|
2022-01-08 00:39:27 +00:00
|
|
|
app.GenesisState{pricefeedtypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&pricefeedGS)},
|
|
|
|
app.GenesisState{types.ModuleName: tApp.AppCodec().MustMarshalJSON(&hardGS)},
|
2020-12-16 21:08:29 +00:00
|
|
|
)
|
2020-12-21 17:18:55 +00:00
|
|
|
keeper := tApp.GetHardKeeper()
|
2020-09-21 21:08:43 +00:00
|
|
|
suite.app = tApp
|
|
|
|
suite.ctx = ctx
|
|
|
|
suite.keeper = keeper
|
|
|
|
|
2020-12-16 21:08:29 +00:00
|
|
|
// Run BeginBlocker once to transition MoneyMarkets
|
2020-12-21 17:18:55 +00:00
|
|
|
hard.BeginBlocker(suite.ctx, suite.keeper)
|
2020-12-16 21:08:29 +00:00
|
|
|
|
2020-09-21 21:08:43 +00:00
|
|
|
// run the test
|
|
|
|
var err error
|
|
|
|
for i := 0; i < tc.args.numberDeposits; i++ {
|
2020-11-12 16:43:28 +00:00
|
|
|
err = suite.keeper.Deposit(suite.ctx, tc.args.depositor, tc.args.amount)
|
2020-09-21 21:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// verify results
|
|
|
|
if tc.errArgs.expectPass {
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
acc := suite.getAccount(tc.args.depositor)
|
2022-01-08 00:39:27 +00:00
|
|
|
suite.Require().Equal(tc.args.expectedAccountBalance, suite.getAccountCoins(acc))
|
2020-09-21 21:08:43 +00:00
|
|
|
mAcc := suite.getModuleAccount(types.ModuleAccountName)
|
2022-01-08 00:39:27 +00:00
|
|
|
suite.Require().Equal(tc.args.expectedModAccountBalance, suite.getAccountCoins(mAcc))
|
2020-12-18 16:05:21 +00:00
|
|
|
dep, f := suite.keeper.GetDeposit(suite.ctx, tc.args.depositor)
|
2020-09-21 21:08:43 +00:00
|
|
|
suite.Require().True(f)
|
2020-12-18 16:05:21 +00:00
|
|
|
suite.Require().Equal(tc.args.expectedDepositCoins, dep.Amount)
|
2020-09-21 21:08:43 +00:00
|
|
|
} else {
|
|
|
|
suite.Require().Error(err)
|
|
|
|
suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 17:56:08 +00:00
|
|
|
|
|
|
|
func (suite *KeeperTestSuite) TestDecrementSuppliedCoins() {
|
|
|
|
type args struct {
|
|
|
|
suppliedInitial sdk.Coins
|
|
|
|
decrementCoins sdk.Coins
|
|
|
|
expectedSuppliedFinal sdk.Coins
|
|
|
|
}
|
|
|
|
type errArgs struct {
|
|
|
|
expectPass bool
|
|
|
|
contains string
|
|
|
|
}
|
|
|
|
type decrementTest struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
errArgs errArgs
|
|
|
|
}
|
|
|
|
testCases := []decrementTest{
|
|
|
|
{
|
|
|
|
"valid",
|
|
|
|
args{
|
|
|
|
suppliedInitial: cs(c("bnb", 10000000000000), c("busd", 3000000000000), c("xrpb", 2500000000000)),
|
|
|
|
decrementCoins: cs(c("bnb", 5000000000000)),
|
|
|
|
expectedSuppliedFinal: cs(c("bnb", 5000000000000), c("busd", 3000000000000), c("xrpb", 2500000000000)),
|
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"valid-negative",
|
|
|
|
args{
|
|
|
|
suppliedInitial: cs(c("bnb", 10000000000000), c("busd", 3000000000000), c("xrpb", 2500000000000)),
|
|
|
|
decrementCoins: cs(c("bnb", 10000000000001)),
|
|
|
|
expectedSuppliedFinal: cs(c("busd", 3000000000000), c("xrpb", 2500000000000)),
|
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"valid-multiple negative",
|
|
|
|
args{
|
|
|
|
suppliedInitial: cs(c("bnb", 10000000000000), c("busd", 3000000000000), c("xrpb", 2500000000000)),
|
|
|
|
decrementCoins: cs(c("bnb", 10000000000001), c("busd", 5000000000000)),
|
|
|
|
expectedSuppliedFinal: cs(c("xrpb", 2500000000000)),
|
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"valid-absent coin denom",
|
|
|
|
args{
|
|
|
|
suppliedInitial: cs(c("bnb", 10000000000000), c("xrpb", 2500000000000)),
|
|
|
|
decrementCoins: cs(c("busd", 5)),
|
|
|
|
expectedSuppliedFinal: cs(c("bnb", 10000000000000), c("xrpb", 2500000000000)),
|
|
|
|
},
|
|
|
|
errArgs{
|
|
|
|
expectPass: true,
|
|
|
|
contains: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
|
|
suite.Run(tc.name, func() {
|
|
|
|
// Initialize test app and set context
|
|
|
|
tApp := app.NewTestApp()
|
2022-01-08 00:39:27 +00:00
|
|
|
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
2021-03-10 17:56:08 +00:00
|
|
|
loanToValue, _ := sdk.NewDecFromStr("0.6")
|
|
|
|
depositor := sdk.AccAddress(crypto.AddressHash([]byte("test")))
|
2022-01-08 00:39:27 +00:00
|
|
|
authGS := app.NewFundedGenStateWithCoins(
|
|
|
|
tApp.AppCodec(),
|
|
|
|
[]sdk.Coins{tc.args.suppliedInitial},
|
|
|
|
[]sdk.AccAddress{depositor},
|
|
|
|
)
|
2021-03-10 17:56:08 +00:00
|
|
|
hardGS := types.NewGenesisState(types.NewParams(
|
|
|
|
types.MoneyMarkets{
|
2023-04-05 23:21:59 +00:00
|
|
|
types.NewMoneyMarket("bnb", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "bnb:usd", sdkmath.NewInt(100000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
|
|
|
types.NewMoneyMarket("busd", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "busd:usd", sdkmath.NewInt(100000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
|
|
|
types.NewMoneyMarket("xrpb", types.NewBorrowLimit(false, sdk.NewDec(1000000000000000), loanToValue), "xrpb:usd", sdkmath.NewInt(100000000), types.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()),
|
2021-03-10 17:56:08 +00:00
|
|
|
},
|
|
|
|
sdk.MustNewDecFromStr("10"),
|
|
|
|
), types.DefaultAccumulationTimes, types.DefaultDeposits, types.DefaultBorrows,
|
|
|
|
types.DefaultTotalSupplied, types.DefaultTotalBorrowed, types.DefaultTotalReserves,
|
|
|
|
)
|
|
|
|
// Pricefeed module genesis state
|
2022-01-08 00:39:27 +00:00
|
|
|
pricefeedGS := pricefeedtypes.GenesisState{
|
|
|
|
Params: pricefeedtypes.Params{
|
|
|
|
Markets: []pricefeedtypes.Market{
|
2021-03-10 17:56:08 +00:00
|
|
|
{MarketID: "xrpb:usd", BaseAsset: "kava", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "busd:usd", BaseAsset: "btcb", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "bnb:usd", BaseAsset: "bnb", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
},
|
|
|
|
},
|
2022-01-08 00:39:27 +00:00
|
|
|
PostedPrices: []pricefeedtypes.PostedPrice{
|
2021-03-10 17:56:08 +00:00
|
|
|
{
|
|
|
|
MarketID: "busd:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("1.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MarketID: "xrpb:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("2.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MarketID: "bnb:usd",
|
|
|
|
OracleAddress: sdk.AccAddress{},
|
|
|
|
Price: sdk.MustNewDecFromStr("200.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
tApp.InitializeFromGenesisStates(authGS,
|
2022-01-08 00:39:27 +00:00
|
|
|
app.GenesisState{pricefeedtypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&pricefeedGS)},
|
|
|
|
app.GenesisState{types.ModuleName: tApp.AppCodec().MustMarshalJSON(&hardGS)},
|
2021-03-10 17:56:08 +00:00
|
|
|
)
|
|
|
|
keeper := tApp.GetHardKeeper()
|
|
|
|
suite.app = tApp
|
|
|
|
suite.ctx = ctx
|
|
|
|
suite.keeper = keeper
|
|
|
|
|
|
|
|
// Run BeginBlocker once to transition MoneyMarkets
|
|
|
|
hard.BeginBlocker(suite.ctx, suite.keeper)
|
|
|
|
|
|
|
|
err := suite.keeper.Deposit(suite.ctx, depositor, tc.args.suppliedInitial)
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
err = suite.keeper.DecrementSuppliedCoins(ctx, tc.args.decrementCoins)
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
totalSuppliedActual, found := suite.keeper.GetSuppliedCoins(suite.ctx)
|
|
|
|
suite.Require().True(found)
|
|
|
|
suite.Require().Equal(totalSuppliedActual, tc.args.expectedSuppliedFinal)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
|
|
|
|
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
|
|
|
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|