-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathmsg_test.go
More file actions
117 lines (102 loc) · 2.58 KB
/
msg_test.go
File metadata and controls
117 lines (102 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//go:build experimental
// +build experimental
package uibc
import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"gotest.tools/v3/assert"
)
func validMsgGovUpdateQuota() MsgGovUpdateQuota {
return MsgGovUpdateQuota{
Title: "update quota",
Authority: authtypes.NewModuleAddress("gov").String(),
Description: "desc",
Total: sdk.MustNewDecFromStr("1000"),
PerDenom: sdk.MustNewDecFromStr("1000"),
QuotaDuration: 100,
}
}
func TestMsgGovUpdateQuota(t *testing.T) {
t.Parallel()
validMsg := validMsgGovUpdateQuota()
invalidAuthority := validMsg
invalidAuthority.Authority = authtypes.NewModuleAddress("govv").String()
invalidTotalQuota := validMsg
invalidTotalQuota.PerDenom = sdk.NewDec(10)
invalidTotalQuota.Total = sdk.NewDec(2)
tests := []struct {
name string
msg MsgGovUpdateQuota
errMsg string
}{
{
name: "valid msg",
msg: validMsg,
errMsg: "",
}, {
name: "invalid authority address in msg",
msg: invalidAuthority,
errMsg: "invalid authority",
}, {
name: "invalid total quota with respect to per denom",
msg: invalidTotalQuota,
errMsg: "total quota must be greater than or equal to per_denom quota",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.errMsg == "" {
assert.NilError(t, err)
} else {
assert.ErrorContains(t, err, tc.errMsg)
}
})
}
}
func validMsgGovSetIBCPause() MsgGovSetIBCPause {
return MsgGovSetIBCPause{
Title: "title",
Authority: authtypes.NewModuleAddress("gov").String(),
Description: "desc",
IbcPauseStatus: 1,
}
}
func TestMsgGovSetIBCPause(t *testing.T) {
t.Parallel()
validMsg := validMsgGovSetIBCPause()
invalidAuthority := validMsg
invalidAuthority.Authority = authtypes.NewModuleAddress("govv").String()
invalidIBCPauseStatus := validMsg
invalidIBCPauseStatus.IbcPauseStatus = 10
tests := []struct {
msg MsgGovSetIBCPause
name string
errMsg string
}{
{
msg: validMsg,
name: "valid msg",
errMsg: "",
}, {
name: "invalid authority address in msg",
msg: invalidAuthority,
errMsg: "invalid authority",
}, {
name: "invalid ibc pause status in msg",
msg: invalidIBCPauseStatus,
errMsg: "invalid ibc-transfer status",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.errMsg == "" {
assert.NilError(t, err)
} else {
assert.ErrorContains(t, err, tc.errMsg)
}
})
}
}