Skip to content

Commit

Permalink
fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 committed Feb 27, 2024
1 parent 69c9879 commit 28be1b0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion protocol/x/clob/keeper/msg_server_place_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28be1b0

Please sign in to comment.