(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func TestKeeper_SetMTP(t *testing.T) { |
| 28 | table := []struct { |
| 29 | name string |
| 30 | mtp types.MTP |
| 31 | err error |
| 32 | errString error |
| 33 | }{ |
| 34 | { |
| 35 | name: "missed defining asset", |
| 36 | mtp: types.MTP{}, |
| 37 | errString: errors.New("no asset specified: mtp invalid"), |
| 38 | }, |
| 39 | { |
| 40 | name: "define asset but no address", |
| 41 | mtp: types.MTP{CollateralAsset: "xxx"}, |
| 42 | errString: errors.New("no address specified: mtp invalid"), |
| 43 | }, |
| 44 | { |
| 45 | name: "define asset and address but no position", |
| 46 | mtp: types.MTP{CollateralAsset: "xxx", Address: "xxx"}, |
| 47 | errString: errors.New("no position specified: mtp invalid"), |
| 48 | }, |
| 49 | { |
| 50 | name: "define asset and address with long position", |
| 51 | mtp: types.MTP{CollateralAsset: "xxx", Address: "xxx", Position: types.Position_LONG}, |
| 52 | }, |
| 53 | { |
| 54 | name: "define asset and address with short position", |
| 55 | mtp: types.MTP{CollateralAsset: "xxx", Address: "xxx", Position: types.Position_SHORT}, |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | for _, tt := range table { |
| 60 | tt := tt |
| 61 | t.Run(tt.name, func(t *testing.T) { |
| 62 | ctx, _, marginKeeper := initKeeper(t) |
| 63 | got := marginKeeper.SetMTP(ctx, &tt.mtp) |
| 64 | |
| 65 | if tt.errString != nil { |
| 66 | require.EqualError(t, got, tt.errString.Error()) |
| 67 | } else if tt.err == nil { |
| 68 | require.NoError(t, got) |
| 69 | } else { |
| 70 | require.ErrorIs(t, got, tt.err) |
| 71 | } |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestKeeper_GetMTP(t *testing.T) { |
| 77 | t.Run("get MTP from a store key that exists", func(t *testing.T) { |
nothing calls this directly
no test coverage detected