Skip to content

Commit

Permalink
test cases and legacy migartion fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnukumavat committed Jan 25, 2024
1 parent 534b0be commit 301b978
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion x/liquidity/keeper/pair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *KeeperTestSuite) TestCreatePair() {
Msg: *types.NewMsgCreatePair(
appID1, addr1, asset1.Denom, asset2.Denom,
),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 2000000000ucmdx"), "insufficient pair creation fee"),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than 2000000000ucmdx"), "insufficient pair creation fee"),
ExpResp: &types.Pair{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand Down
10 changes: 5 additions & 5 deletions x/liquidity/keeper/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (s *KeeperTestSuite) TestCreatePool() {
Msg: *types.NewMsgCreatePool(
appID1, addr1, dummyPair1.Id, sdk.NewCoins(sdk.NewCoin(dummyPair1.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair1.QuoteCoinDenom, sdkmath.NewInt(1000000000000))),
),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom, dummyPair1.QuoteCoinDenom),
ExpResp: &types.Pool{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand All @@ -138,7 +138,7 @@ func (s *KeeperTestSuite) TestCreatePool() {
Msg: *types.NewMsgCreatePool(
appID1, addr1, dummyPair2.Id, sdk.NewCoins(sdk.NewCoin(dummyPair2.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair2.QuoteCoinDenom, sdkmath.NewInt(1000000000000))),
),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"),
ExpResp: &types.Pool{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand Down Expand Up @@ -453,7 +453,7 @@ func (s *KeeperTestSuite) TestDeposit() {
Msg: *types.NewMsgDeposit(
appID1, addr1, app1Pool.Id, sdk.NewCoins(sdk.NewCoin(app1Pair.BaseCoinDenom, sdkmath.NewInt(100000000)), sdk.NewCoin(app1Pair.QuoteCoinDenom, sdkmath.NewInt(100000000))),
),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 100000000%s", app1Pair.BaseCoinDenom),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 100000000%s", app1Pair.BaseCoinDenom, app1Pair.BaseCoinDenom),
ExpResp: &types.DepositRequest{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (s *KeeperTestSuite) TestCreateRangedPool() {
appID1, addr1, dummyPair1.Id, sdk.NewCoins(sdk.NewCoin(dummyPair1.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair1.QuoteCoinDenom, sdkmath.NewInt(1000000000000))),
sdkmath.LegacyMustNewDecFromStr("0.99"), sdkmath.LegacyMustNewDecFromStr("1.01"), sdkmath.LegacyMustNewDecFromStr("1"),
),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom),
ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom, dummyPair1.QuoteCoinDenom),
ExpResp: &types.Pool{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand All @@ -1072,7 +1072,7 @@ func (s *KeeperTestSuite) TestCreateRangedPool() {
appID1, addr1, dummyPair2.Id, sdk.NewCoins(sdk.NewCoin(dummyPair2.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair2.QuoteCoinDenom, sdkmath.NewInt(1000000000000))),
sdkmath.LegacyMustNewDecFromStr("0.99"), sdkmath.LegacyMustNewDecFromStr("1.01"), sdkmath.LegacyMustNewDecFromStr("1"),
),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"),
ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"),
ExpResp: &types.Pool{},
QueryResponseIndex: 0,
QueryResponse: nil,
Expand Down
11 changes: 6 additions & 5 deletions x/liquidity/legacy/v1/liquidity.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions x/liquidity/legacy/v1/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions x/liquidity/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/cometbft/cometbft/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/comdex-official/comdex/x/liquidity/amm"
"github.com/comdex-official/comdex/x/liquidity/expected"
Expand Down Expand Up @@ -57,15 +56,12 @@ func (op *BulkSendCoinsOperation) QueueSendCoins(
// Run runs BankKeeper.InputOutputCoins once for queued operations.
func (op *BulkSendCoinsOperation) Run(ctx sdk.Context, bankKeeper expected.BankKeeper) error {
if len(op.txs) > 0 {
var (
inputs []banktypes.Input
outputs []banktypes.Output
)
for _, tx := range op.txs {
inputs = append(inputs, banktypes.NewInput(tx.from, tx.amt))
outputs = append(outputs, banktypes.NewOutput(tx.to, tx.amt))
if err := bankKeeper.SendCoins(ctx, tx.from, tx.to, tx.amt); err != nil {
return err
}
}
return bankKeeper.InputOutputCoins(ctx, inputs, outputs)
return nil
}
return nil
}
Expand Down

0 comments on commit 301b978

Please sign in to comment.