Skip to content

Commit

Permalink
[CLOB-166] - add e2e tests for fok/ioc/po short term orders (#771)
Browse files Browse the repository at this point in the history
* add e2e tests for fok/ioc/po short term orders

* Update protocol/x/clob/e2e/short_term_orders_test.go

Co-authored-by: Jonathan Fung <[email protected]>

* Update protocol/x/clob/e2e/short_term_orders_test.go

Co-authored-by: Jonathan Fung <[email protected]>

* add tests for both side of the book

---------

Co-authored-by: Jonathan Fung <[email protected]>
  • Loading branch information
jakob-dydx and jonfung-dydx authored Nov 8, 2023
1 parent 7585cad commit 238427b
Show file tree
Hide file tree
Showing 3 changed files with 682 additions and 4 deletions.
109 changes: 107 additions & 2 deletions protocol/testutil/constants/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,20 @@ var (
Subticks: 10000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 22},
}
Order_Bob_Num0_Id8_Clob1_Sell5_Price10_GTB22 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 8, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 5,
Subticks: 10,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 22},
}
Order_Bob_Num0_Id8_Clob1_Sell20_Price10_GTB22 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 8, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 20,
Subticks: 10,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 22},
}
Order_Bob_Num0_Id8_Clob0_Sell20_Price10_GTB22 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 8, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Expand All @@ -435,13 +449,34 @@ var (
Subticks: 10000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 22},
}
Order_Bob_Num0_Id11_Clob1_Sell5_Price15_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 11, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 5,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id11_Clob1_Buy5_Price40_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 11, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 5,
Subticks: 40,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id12_Clob0_Buy5_Price5_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 5,
Subticks: 5,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id12_Clob0_Buy5_Price40_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 5,
Subticks: 40,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id12_Clob1_Buy5_Price40_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Expand All @@ -456,6 +491,20 @@ var (
Subticks: 40,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 32},
}
Order_Bob_Num0_Id12_Clob0_Sell20_Price5_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 20,
Subticks: 5,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id12_Clob0_Sell20_Price15_GTB20 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 20,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
}
Order_Bob_Num0_Id12_Clob0_Sell20_Price35_GTB32 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Bob_Num0, ClientId: 12, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Expand Down Expand Up @@ -879,6 +928,38 @@ var (
}

// IOC orders.
Order_Alice_Num0_Id1_Clob1_Buy5_Price15_GTB20_IOC = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 5,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_IOC,
}
Order_Alice_Num0_Id1_Clob1_Sell5_Price15_GTB20_IOC = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 5,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_IOC,
}
Order_Alice_Num0_Id1_Clob1_Buy10_Price15_GTB20_IOC = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 10,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_IOC,
}
Order_Alice_Num0_Id1_Clob1_Sell10_Price15_GTB20_IOC = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 10,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_IOC,
}
Order_Alice_Num1_Id1_Clob1_Sell10_Price15_GTB20_IOC = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num1, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Expand All @@ -897,14 +978,30 @@ var (
}

// Fill-or-kill orders.
Order_Alice_Num0_Id0_Clob1_Sell10_Price15_GTB20_FOK = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 0, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 10,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_FILL_OR_KILL,
}
Order_Alice_Num0_Id0_Clob1_Buy10_Price15_GTB20_FOK = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 0, ClobPairId: 0},
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 0, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 10,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_FILL_OR_KILL,
}
Order_Alice_Num0_Id0_Clob1_Buy20_Price15_GTB20_FOK = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 0, ClobPairId: 1},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 20,
Subticks: 15,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_FILL_OR_KILL,
}
Order_Alice_Num1_Id1_Clob1_Sell10_Price15_GTB20_FOK = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num1, ClientId: 1, ClobPairId: 1},
Side: clobtypes.Order_SIDE_SELL,
Expand Down Expand Up @@ -1071,12 +1168,20 @@ var (
}

// Post-only orders.
Order_Alice_Num0_Id1_Clob0_Sell15_Price10_GTB18_PO = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 15,
Subticks: 10,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 18},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
}
Order_Alice_Num0_Id1_Clob0_Buy15_Price10_GTB18_PO = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 15,
Subticks: 10,
GoodTilOneof: &clobtypes.Order_GoodTilBlockTime{GoodTilBlockTime: 18},
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 18},
TimeInForce: clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
}
Order_Alice_Num1_Id1_Clob1_Sell10_Price15_GTB20_PO = clobtypes.Order{
Expand Down
5 changes: 3 additions & 2 deletions protocol/testutil/msgs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ type TestBlockWithMsgs struct {
}

type TestSdkMsg struct {
Msg sdk.Msg
ExpectedIsOk bool
Msg sdk.Msg
ExpectedIsOk bool
ExpectedRespCode uint32
}

// SampleMsg is a struct containing a sample msg and its name.
Expand Down
Loading

0 comments on commit 238427b

Please sign in to comment.