@@ -73,39 +73,28 @@ func (suite *KeeperTestSuite) TestQueryKeys() {
73
73
}
74
74
75
75
func (suite * KeeperTestSuite ) TestQueryKey () {
76
- ctx , queryClient := suite .ctx , suite .queryClient
77
-
78
- // setup
79
- for _ , key := range suite .validKeys {
80
- suite .restakeKeeper .SetKey (ctx , key )
81
- }
76
+ queryClient := suite .queryClient
77
+ suite .setupState ()
82
78
83
79
// query and check
84
80
res , err := queryClient .Key (context .Background (), & types.QueryKeyRequest {
85
- Key : "Key0" ,
81
+ Key : ValidKey1 ,
86
82
})
87
83
suite .Require ().NoError (err )
88
84
suite .Require ().Equal (& types.QueryKeyResponse {
89
85
Key : suite .validKeys [0 ],
90
86
}, res )
91
87
92
88
res , err = queryClient .Key (context .Background (), & types.QueryKeyRequest {
93
- Key : "nonKey" ,
89
+ Key : InvalidKey ,
94
90
})
95
91
suite .Require ().ErrorContains (err , "key not found" )
96
92
suite .Require ().Nil (res )
97
93
}
98
94
99
95
func (suite * KeeperTestSuite ) TestQueryRewards () {
100
- ctx , queryClient := suite .ctx , suite .queryClient
101
-
102
- // setup
103
- for _ , key := range suite .validKeys {
104
- suite .restakeKeeper .SetKey (ctx , key )
105
- }
106
- for _ , lock := range suite .validLocks {
107
- suite .restakeKeeper .SetLock (ctx , lock )
108
- }
96
+ queryClient := suite .queryClient
97
+ suite .setupState ()
109
98
110
99
// query and check
111
100
var (
@@ -127,11 +116,11 @@ func (suite *KeeperTestSuite) TestQueryRewards() {
127
116
expRes = & types.QueryRewardsResponse {
128
117
Rewards : []* types.Reward {
129
118
{
130
- Key : "Key0" ,
119
+ Key : ValidKey1 ,
131
120
Rewards : sdk .NewDecCoins (sdk .NewDecCoin ("uband" , sdkmath .NewInt (1 ))),
132
121
},
133
122
{
134
- Key : "Key1" ,
123
+ Key : ValidKey2 ,
135
124
Rewards : nil ,
136
125
},
137
126
},
@@ -148,7 +137,7 @@ func (suite *KeeperTestSuite) TestQueryRewards() {
148
137
expRes = & types.QueryRewardsResponse {
149
138
Rewards : []* types.Reward {
150
139
{
151
- Key : "Key0" ,
140
+ Key : ValidKey1 ,
152
141
Rewards : sdk .NewDecCoins (sdk .NewDecCoin ("uband" , sdkmath .NewInt (1 ))),
153
142
},
154
143
},
@@ -188,15 +177,8 @@ func (suite *KeeperTestSuite) TestQueryRewards() {
188
177
}
189
178
190
179
func (suite * KeeperTestSuite ) TestQueryLocks () {
191
- ctx , queryClient := suite .ctx , suite .queryClient
192
-
193
- // setup
194
- for _ , key := range suite .validKeys {
195
- suite .restakeKeeper .SetKey (ctx , key )
196
- }
197
- for _ , lock := range suite .validLocks {
198
- suite .restakeKeeper .SetLock (ctx , lock )
199
- }
180
+ queryClient := suite .queryClient
181
+ suite .setupState ()
200
182
201
183
// query and check
202
184
var (
@@ -218,11 +200,11 @@ func (suite *KeeperTestSuite) TestQueryLocks() {
218
200
expRes = & types.QueryLocksResponse {
219
201
Locks : []* types.LockResponse {
220
202
{
221
- Key : "Key0" ,
203
+ Key : ValidKey1 ,
222
204
Amount : sdkmath .NewInt (10 ),
223
205
},
224
206
{
225
- Key : "Key1" ,
207
+ Key : ValidKey2 ,
226
208
Amount : sdkmath .NewInt (100 ),
227
209
},
228
210
},
@@ -239,7 +221,7 @@ func (suite *KeeperTestSuite) TestQueryLocks() {
239
221
expRes = & types.QueryLocksResponse {
240
222
Locks : []* types.LockResponse {
241
223
{
242
- Key : "Key0" ,
224
+ Key : ValidKey1 ,
243
225
Amount : sdkmath .NewInt (10 ),
244
226
},
245
227
},
0 commit comments