-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch to use the helper method to create positions #1787
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,19 @@ import ( | |
"fmt" | ||
"math" | ||
|
||
appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" | ||
"math/big" | ||
"testing" | ||
|
||
appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" | ||
|
||
networktestutil "github.com/cosmos/cosmos-sdk/testutil/network" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/dtypes" | ||
"github.com/dydxprotocol/v4-chain/protocol/lib" | ||
testutil "github.com/dydxprotocol/v4-chain/protocol/testutil/util" | ||
assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/clob/client/testutil" | ||
clob_testutil "github.com/dydxprotocol/v4-chain/protocol/x/clob/client/testutil" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Clarify the specific utility of The review comment is valid. There are no comments or documentation explaining the specific utility of
Analysis chainClarify the specific utility of It's important to maintain clear documentation or comments explaining the specific utilities provided by Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for documentation or comments regarding `clob_testutil` usage.
rg --type python --files-with-matches 'clob_testutil' | xargs rg 'clob_testutil' --context 5
Length of output: 3231 Script: #!/bin/bash
# Description: Check for documentation or comments regarding `clob_testutil` usage in Go files.
rg --type go --files-with-matches 'clob_testutil' | xargs rg 'clob_testutil' --context 5
Length of output: 1480 |
||
"github.com/dydxprotocol/v4-chain/protocol/x/clob/types" | ||
epochstypes "github.com/dydxprotocol/v4-chain/protocol/x/epochs/types" | ||
feetierstypes "github.com/dydxprotocol/v4-chain/protocol/x/feetiers/types" | ||
|
@@ -128,7 +129,7 @@ func (s *LiquidationsIntegrationTestSuite) SetupSuite() { | |
s.cfg.GenesisState[types.ModuleName] = buf | ||
|
||
// Set the balances in the genesis state. | ||
s.cfg.GenesisState[banktypes.ModuleName] = testutil.CreateBankGenesisState( | ||
s.cfg.GenesisState[banktypes.ModuleName] = clob_testutil.CreateBankGenesisState( | ||
s.T(), | ||
s.cfg, | ||
liqTestInitialSubaccountModuleAccBalance, | ||
|
@@ -147,16 +148,17 @@ func (s *LiquidationsIntegrationTestSuite) SetupSuite() { | |
satypes.Subaccount{ | ||
Id: &satypes.SubaccountId{Owner: s.validatorAddress.String(), Number: liqTestSubaccountNumberOne}, | ||
AssetPositions: []*satypes.AssetPosition{ | ||
{ | ||
AssetId: assettypes.AssetUsdc.Id, | ||
Quantums: dtypes.NewInt(-45_001_000_000), // -$45,001 | ||
}, | ||
testutil.CreateSingleAssetPosition( | ||
assettypes.AssetUsdc.Id, | ||
big.NewInt(-45_001_000_000), // -$45,001 | ||
), | ||
}, | ||
PerpetualPositions: []*satypes.PerpetualPosition{ | ||
{ | ||
PerpetualId: 0, | ||
Quantums: dtypes.NewInt(100_000_000), // 1 BTC | ||
}, | ||
testutil.CreateSinglePerpetualPosition( | ||
0, | ||
big.NewInt(100_000_000), // 1 BTC | ||
big.NewInt(0), | ||
), | ||
}, | ||
}, | ||
) | ||
|
@@ -211,7 +213,7 @@ func (s *LiquidationsIntegrationTestSuite) TestCLILiquidations() { | |
subticks := types.Subticks(50_000_000_000) | ||
|
||
// Place the maker order that should be filled by the liquidation order. | ||
_, err = testutil.MsgPlaceOrderExec( | ||
_, err = clob_testutil.MsgPlaceOrderExec( | ||
ctx, | ||
s.validatorAddress, | ||
liqTestSubaccountNumberZero, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor using
testutil
functions for position creation:The replacement of direct instantiation with
testutil.CreateSingleAssetPosition
andtestutil.CreateSinglePerpetualPosition
is a significant improvement. This change not only reduces redundancy but also enhances the maintainability and readability of the test code by centralizing the creation logic.Consider adding a brief comment above these utility function calls to explain what each parameter represents, especially for magic numbers like
0
or large integers like55_000_000_000
, to enhance code readability.Also applies to: 368-378, 448-458, 526-536