(t *testing.T)
| 818 | } |
| 819 | |
| 820 | func TestKeeper_OpenClose(t *testing.T) { |
| 821 | table := []struct { |
| 822 | name string |
| 823 | externalAsset string |
| 824 | err error |
| 825 | errString error |
| 826 | }{ |
| 827 | { |
| 828 | name: "one round open/close long position", |
| 829 | externalAsset: "xxx", |
| 830 | // errString: errors.New("pool health too low to open new positions: margin not enabled for pool"), |
| 831 | // errString: errors.New("rowan: using rowan as collateral asset is not allowed"), |
| 832 | }, |
| 833 | } |
| 834 | |
| 835 | for _, tt := range table { |
| 836 | tt := tt |
| 837 | t.Run(tt.name, func(t *testing.T) { |
| 838 | ctx, app := test.CreateTestAppMargin(false) |
| 839 | marginKeeper := app.MarginKeeper |
| 840 | |
| 841 | app.ClpKeeper.SetSwapFeeParams(ctx, clptypes.GetDefaultSwapFeeParams()) |
| 842 | |
| 843 | app.TokenRegistryKeeper.SetToken(ctx, &tokenregistrytypes.RegistryEntry{ |
| 844 | Denom: tt.externalAsset, |
| 845 | Decimals: 18, |
| 846 | Permissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, |
| 847 | }) |
| 848 | |
| 849 | params := types.Params{ |
| 850 | LeverageMax: sdk.NewDec(2), |
| 851 | InterestRateMax: sdk.NewDec(1), |
| 852 | InterestRateMin: sdk.NewDecWithPrec(1, 1), |
| 853 | InterestRateIncrease: sdk.NewDecWithPrec(1, 1), |
| 854 | InterestRateDecrease: sdk.NewDecWithPrec(1, 1), |
| 855 | HealthGainFactor: sdk.NewDecWithPrec(1, 2), |
| 856 | EpochLength: 0, |
| 857 | RemovalQueueThreshold: sdk.ZeroDec(), |
| 858 | ForceCloseFundPercentage: sdk.NewDecWithPrec(1, 1), |
| 859 | ForceCloseFundAddress: "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", |
| 860 | IncrementalInterestPaymentFundPercentage: sdk.NewDecWithPrec(1, 1), |
| 861 | IncrementalInterestPaymentFundAddress: "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", |
| 862 | IncrementalInterestPaymentEnabled: false, |
| 863 | PoolOpenThreshold: sdk.NewDecWithPrec(1, 1), |
| 864 | MaxOpenPositions: 10000, |
| 865 | SqModifier: sdk.MustNewDecFromStr("10000000000000000000000000"), |
| 866 | SafetyFactor: sdk.MustNewDecFromStr("1.05"), |
| 867 | Pools: []string{tt.externalAsset}, |
| 868 | RowanCollateralEnabled: true, |
| 869 | } |
| 870 | expectedGenesis := types.GenesisState{Params: ¶ms} |
| 871 | marginKeeper.InitGenesis(ctx, expectedGenesis) |
| 872 | genesis := marginKeeper.ExportGenesis(ctx) |
| 873 | require.Equal(t, expectedGenesis, *genesis) |
| 874 | |
| 875 | msgServer := keeper.NewMsgServerImpl(marginKeeper) |
| 876 | |
| 877 | nativeAsset := clptypes.NativeSymbol |
nothing calls this directly
no test coverage detected