Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Oct 13, 2023
1 parent 66e8763 commit b426451
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions x/margin/client/cli/query_mtp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func networkWithMTPObjects(t *testing.T, n int) (*network.Network, []*types.MTP)
for i := 0; i < n; i++ {
mtp := types.MTP{
Address: addr[i].String(),
Collaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
Liabilities: sdk.NewInt(0),
InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))),
InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))),
InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
InterestPaidCustodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))},
InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))},
Leverages: []sdk.Dec{sdk.NewDec(0)},
MtpHealth: sdk.NewDec(0),
Position: types.Position_LONG,
Expand Down
18 changes: 9 additions & 9 deletions x/margin/keeper/close_long_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestCloseLong_AmmPoolNotFound(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
)

Expand Down Expand Up @@ -123,8 +123,8 @@ func TestCloseLong_ErrorHandleInterest(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -162,8 +162,8 @@ func TestCloseLong_ErrorTakeOutCustody(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -202,8 +202,8 @@ func TestCloseLong_ErrorEstimateAndRepay(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -243,8 +243,8 @@ func TestCloseLong_SuccessfulClosingLongPosition(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down
18 changes: 9 additions & 9 deletions x/margin/keeper/close_short_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestCloseShort_AmmPoolNotFound(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
}
)

Expand Down Expand Up @@ -123,8 +123,8 @@ func TestCloseShort_ErrorHandleInterest(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -162,8 +162,8 @@ func TestCloseShort_ErrorTakeOutCustody(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -202,8 +202,8 @@ func TestCloseShort_ErrorEstimateAndRepay(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down Expand Up @@ -243,8 +243,8 @@ func TestCloseShort_SuccessfulClosingLongPosition(t *testing.T) {
}
mtp = types.MTP{
AmmPoolId: 2,
Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))),
Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))),
Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))},
Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))},
}
pool = types.Pool{
InterestRate: math.LegacyNewDec(2),
Expand Down
4 changes: 2 additions & 2 deletions x/margin/keeper/invariant_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func TestCheckBalanceInvariant_InvalidBalance(t *testing.T) {

// Create a pool
// Mint 100000USDC
usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000)))
usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))}
// Mint 100000ATOM
atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000)))
atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))}

err := app.BankKeeper.MintCoins(ctx, types.ModuleName, usdcToken)
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions x/margin/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func TestSetGetMTP(t *testing.T) {
for i := 0; i < 2; i++ {
mtp := types.MTP{
Address: addr[i].String(),
Collaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
Collaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
Liabilities: sdk.NewInt(0),
InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))),
InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))),
InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
InterestPaidCustodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))},
InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))},
Custodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))},
Leverages: []sdk.Dec{sdk.NewDec(0)},
MtpHealth: sdk.NewDec(0),
Position: types.Position_LONG,
Expand Down
8 changes: 4 additions & 4 deletions x/margin/keeper/open_long_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ func TestOpenLong_BaseCurrency_Collateral(t *testing.T) {

// Create a pool
// Mint 100000USDC
usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000)))
usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))}
// Mint 100000ATOM
atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000)))
atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))}

err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken)
require.NoError(t, err)
Expand Down Expand Up @@ -521,9 +521,9 @@ func TestOpenLong_ATOM_Collateral(t *testing.T) {

// Create a pool
// Mint 100000USDC
usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000)))
usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))}
// Mint 100000ATOM
atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000)))
atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))}

err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion x/margin/keeper/open_short_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (k Keeper) ProcessOpenShort(ctx sdk.Context, mtp *types.MTP, leverage sdk.D

// if position is short then override the custody asset to the base currency
if mtp.Position == types.Position_SHORT {
mtp.Custodies = sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0)))
mtp.Custodies = []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}
}

// Borrow the asset the user wants to short.
Expand Down
8 changes: 4 additions & 4 deletions x/margin/keeper/open_short_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ func TestOpenShort_BaseCurrency_Collateral(t *testing.T) {

// Create a pool
// Mint 100000USDC
usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000)))
usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))}
// Mint 100000ATOM
atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000)))
atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))}

err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken)
require.NoError(t, err)
Expand Down Expand Up @@ -546,9 +546,9 @@ func TestOpenShort_ATOM_Collateral(t *testing.T) {

// Create a pool
// Mint 100000USDC
usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000)))
usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))}
// Mint 100000ATOM
atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000)))
atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))}

err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken)
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions x/margin/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func GetPositionFromString(s string) Position {
func NewMTP(signer string, collateralAsset string, borrowAsset string, position Position, leverage sdk.Dec, poolId uint64) *MTP {
return &MTP{
Address: signer,
Collaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.ZeroInt())),
Collaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())},
Liabilities: sdk.ZeroInt(),
InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.NewInt(0))),
InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin(borrowAsset, sdk.NewInt(0))),
InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.NewInt(0))),
Custodies: sdk.NewCoins(sdk.NewCoin(borrowAsset, sdk.ZeroInt())),
InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())},
InterestPaidCustodies: []sdk.Coin{sdk.NewCoin(borrowAsset, sdk.ZeroInt())},
InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())},
Custodies: []sdk.Coin{sdk.NewCoin(borrowAsset, sdk.ZeroInt())},
Leverages: []sdk.Dec{leverage},
MtpHealth: sdk.ZeroDec(),
Position: position,
Expand Down

0 comments on commit b426451

Please sign in to comment.