From 28be1b09074a920d3ae9064b25e513c7d49b6110 Mon Sep 17 00:00:00 2001 From: Jay Yu <103467857+jayy04@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:47:20 -0500 Subject: [PATCH] fix e2e test --- .../keeper/msg_server_place_order_test.go | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/protocol/x/clob/keeper/msg_server_place_order_test.go b/protocol/x/clob/keeper/msg_server_place_order_test.go index 39ce10a079..a1b6a41e4c 100644 --- a/protocol/x/clob/keeper/msg_server_place_order_test.go +++ b/protocol/x/clob/keeper/msg_server_place_order_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/dydxprotocol/v4-chain/protocol/dtypes" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" "github.com/dydxprotocol/v4-chain/protocol/lib" @@ -48,9 +49,14 @@ func TestPlaceOrder_Error(t *testing.T) { ExpectedError: types.ErrTimeExceedsGoodTilBlockTime, }, "Returns an error when collateralization check fails": { - StatefulOrderPlacement: constants.LongTermOrder_Bob_Num0_Id2_Clob0_Buy15_Price5_GTBT10, + StatefulOrderPlacement: constants.LongTermOrder_Alice_Num0_Id1_Clob0_Buy1BTC_Price50000_GTBT15, ExpectedError: types.ErrStatefulOrderCollateralizationCheckFailed, }, + "Returns an error when equity tier check fails": { + // Bob has TNC of $0. + StatefulOrderPlacement: constants.LongTermOrder_Bob_Num0_Id2_Clob0_Buy15_Price5_GTBT10, + ExpectedError: types.ErrOrderWouldExceedMaxOpenOrdersEquityTierLimit, + }, "Returns an error when order replacement is attempted": { StatefulOrders: []types.Order{ constants.LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTBT15, @@ -128,6 +134,27 @@ func TestPlaceOrder_Error(t *testing.T) { ) require.NoError(t, err) + ks.SubaccountsKeeper.SetSubaccount(ks.Ctx, constants.Alice_Num0_10_000USD) + + err = ks.ClobKeeper.InitializeEquityTierLimit( + ks.Ctx, + types.EquityTierLimitConfiguration{ + ShortTermOrderEquityTiers: []types.EquityTierLimit{ + { + UsdTncRequired: dtypes.NewInt(20_000_000), + Limit: 5, + }, + }, + StatefulOrderEquityTiers: []types.EquityTierLimit{ + { + UsdTncRequired: dtypes.NewInt(20_000_000), + Limit: 5, + }, + }, + }, + ) + require.NoError(t, err) + // Create ClobPair. clobPair := constants.ClobPair_Btc // PerpetualMarketCreateEvents are emitted when initializing the genesis state, so we need to mock