MCPcopy Create free account
hub / github.com/Sifchain/sifnode / TestKeeper_SetMTP

Function TestKeeper_SetMTP

x/margin/keeper/keeper_test.go:27–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func 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
76func TestKeeper_GetMTP(t *testing.T) {
77 t.Run("get MTP from a store key that exists", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

initKeeperFunction · 0.85
SetMTPMethod · 0.65
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected