forked from dydxprotocol/v4-chain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLOB-914] Ensure that the rate limiting is only occurring during `Ch…
…eckTx` and `ReCheckTx`. (dydxprotocol#488) * [CLOB-914] Ensure that the rate limiting is only occurring during `CheckTx` and `ReCheckTx`.
- Loading branch information
Showing
3 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package keeper_test | ||
|
||
import ( | ||
testApp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" | ||
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants" | ||
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestRateLimitPlaceOrderIsNoopOutsideOfCheckTxAndReCheckTx(t *testing.T) { | ||
tApp := testApp.NewTestAppBuilder().WithTesting(t).Build() | ||
checkTxCtx := tApp.AdvanceToBlock(21, testApp.AdvanceToBlockOptions{}) | ||
deliverTxCtx := checkTxCtx.WithIsCheckTx(false).WithIsReCheckTx(false) | ||
msg := clobtypes.NewMsgPlaceOrder(constants.Order_Alice_Num0_Id0_Clob0_Buy5_Price5_GTB20) | ||
|
||
// We expect an error and that the GTB is out of bounds. | ||
require.Error( | ||
t, | ||
tApp.App.ClobKeeper.RateLimitPlaceOrder(checkTxCtx, msg), | ||
"GoodTilBlock 20 is less than the current blockHeight 22", | ||
) | ||
|
||
// We don't expect any checks from occurring. | ||
require.Nil(t, tApp.App.ClobKeeper.RateLimitPlaceOrder(deliverTxCtx, msg)) | ||
} | ||
|
||
func TestRateLimitCancelOrderIsNoopOutsideOfCheckTxAndReCheckTx(t *testing.T) { | ||
tApp := testApp.NewTestAppBuilder().WithTesting(t).Build() | ||
checkTxCtx := tApp.AdvanceToBlock(21, testApp.AdvanceToBlockOptions{}) | ||
deliverTxCtx := checkTxCtx.WithIsCheckTx(false).WithIsReCheckTx(false) | ||
msg := clobtypes.NewMsgCancelOrderShortTerm(constants.Order_Alice_Num0_Id0_Clob0_Buy5_Price5_GTB20.OrderId, 20) | ||
|
||
// We expect an error and that the GTB is out of bounds. | ||
require.Error( | ||
t, | ||
tApp.App.ClobKeeper.RateLimitCancelOrder(checkTxCtx, msg), | ||
"GoodTilBlock 20 is less than the current blockHeight 22", | ||
) | ||
|
||
// We don't expect any checks from occurring. | ||
require.Nil(t, tApp.App.ClobKeeper.RateLimitCancelOrder(deliverTxCtx, msg)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters