6
6
7
7
"github.com/cosmos/cosmos-sdk/baseapp"
8
8
"github.com/cosmos/cosmos-sdk/codec"
9
- "github.com/cosmos/cosmos-sdk/simapp/helpers"
10
9
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
11
10
sdk "github.com/cosmos/cosmos-sdk/types"
12
11
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -93,34 +92,24 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper,
93
92
account := ak .GetAccount (ctx , simAccount .Address )
94
93
spendable := bk .SpendableCoins (ctx , account .GetAddress ())
95
94
96
- fees , err := simtypes .RandomFees (r , ctx , spendable )
97
- if err != nil {
98
- return simtypes .NoOpMsg (types .ModuleName , types .TypeMsgSetWithdrawAddress , "unable to generate fees" ), nil , err
99
- }
100
-
101
95
msg := types .NewMsgSetWithdrawAddress (simAccount .Address , simToAccount .Address )
102
96
103
- txGen := simappparams .MakeTestEncodingConfig ().TxConfig
104
- tx , err := helpers .GenTx (
105
- txGen ,
106
- []sdk.Msg {msg },
107
- fees ,
108
- helpers .DefaultGenTxGas ,
109
- chainID ,
110
- []uint64 {account .GetAccountNumber ()},
111
- []uint64 {account .GetSequence ()},
112
- simAccount .PrivKey ,
113
- )
114
- if err != nil {
115
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to generate mock tx" ), nil , err
116
- }
117
-
118
- _ , _ , err = app .Deliver (txGen .TxEncoder (), tx )
119
- if err != nil {
120
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to deliver tx" ), nil , err
121
- }
122
-
123
- return simtypes .NewOperationMsg (msg , true , "" , nil ), nil , nil
97
+ txCtx := simulation.OperationInput {
98
+ R : r ,
99
+ App : app ,
100
+ TxGen : simappparams .MakeTestEncodingConfig ().TxConfig ,
101
+ Cdc : nil ,
102
+ Msg : msg ,
103
+ MsgType : msg .Type (),
104
+ Context : ctx ,
105
+ SimAccount : simAccount ,
106
+ AccountKeeper : ak ,
107
+ Bankkeeper : bk ,
108
+ ModuleName : types .ModuleName ,
109
+ CoinsSpentInMsg : spendable ,
110
+ }
111
+
112
+ return simulation .GenAndDeliverTxWithRandFees (txCtx )
124
113
}
125
114
}
126
115
@@ -145,34 +134,24 @@ func SimulateMsgWithdrawDelegatorReward(ak types.AccountKeeper, bk types.BankKee
145
134
account := ak .GetAccount (ctx , simAccount .Address )
146
135
spendable := bk .SpendableCoins (ctx , account .GetAddress ())
147
136
148
- fees , err := simtypes .RandomFees (r , ctx , spendable )
149
- if err != nil {
150
- return simtypes .NoOpMsg (types .ModuleName , types .TypeMsgWithdrawDelegatorReward , "unable to generate fees" ), nil , err
151
- }
152
-
153
137
msg := types .NewMsgWithdrawDelegatorReward (simAccount .Address , validator .GetOperator ())
154
138
155
- txGen := simappparams .MakeTestEncodingConfig ().TxConfig
156
- tx , err := helpers .GenTx (
157
- txGen ,
158
- []sdk.Msg {msg },
159
- fees ,
160
- helpers .DefaultGenTxGas ,
161
- chainID ,
162
- []uint64 {account .GetAccountNumber ()},
163
- []uint64 {account .GetSequence ()},
164
- simAccount .PrivKey ,
165
- )
166
- if err != nil {
167
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to generate mock tx" ), nil , err
168
- }
169
-
170
- _ , _ , err = app .Deliver (txGen .TxEncoder (), tx )
171
- if err != nil {
172
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to deliver tx" ), nil , err
173
- }
174
-
175
- return simtypes .NewOperationMsg (msg , true , "" , nil ), nil , nil
139
+ txCtx := simulation.OperationInput {
140
+ R : r ,
141
+ App : app ,
142
+ TxGen : simappparams .MakeTestEncodingConfig ().TxConfig ,
143
+ Cdc : nil ,
144
+ Msg : msg ,
145
+ MsgType : msg .Type (),
146
+ Context : ctx ,
147
+ SimAccount : simAccount ,
148
+ AccountKeeper : ak ,
149
+ Bankkeeper : bk ,
150
+ ModuleName : types .ModuleName ,
151
+ CoinsSpentInMsg : spendable ,
152
+ }
153
+
154
+ return simulation .GenAndDeliverTxWithRandFees (txCtx )
176
155
}
177
156
}
178
157
@@ -200,34 +179,24 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban
200
179
account := ak .GetAccount (ctx , simAccount .Address )
201
180
spendable := bk .SpendableCoins (ctx , account .GetAddress ())
202
181
203
- fees , err := simtypes .RandomFees (r , ctx , spendable )
204
- if err != nil {
205
- return simtypes .NoOpMsg (types .ModuleName , types .TypeMsgWithdrawValidatorCommission , "unable to generate fees" ), nil , err
206
- }
207
-
208
182
msg := types .NewMsgWithdrawValidatorCommission (validator .GetOperator ())
209
183
210
- txGen := simappparams .MakeTestEncodingConfig ().TxConfig
211
- tx , err := helpers .GenTx (
212
- txGen ,
213
- []sdk.Msg {msg },
214
- fees ,
215
- helpers .DefaultGenTxGas ,
216
- chainID ,
217
- []uint64 {account .GetAccountNumber ()},
218
- []uint64 {account .GetSequence ()},
219
- simAccount .PrivKey ,
220
- )
221
- if err != nil {
222
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to generate mock tx" ), nil , err
223
- }
224
-
225
- _ , _ , err = app .Deliver (txGen .TxEncoder (), tx )
226
- if err != nil {
227
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to deliver tx" ), nil , err
228
- }
229
-
230
- return simtypes .NewOperationMsg (msg , true , "" , nil ), nil , nil
184
+ txCtx := simulation.OperationInput {
185
+ R : r ,
186
+ App : app ,
187
+ TxGen : simappparams .MakeTestEncodingConfig ().TxConfig ,
188
+ Cdc : nil ,
189
+ Msg : msg ,
190
+ MsgType : msg .Type (),
191
+ Context : ctx ,
192
+ SimAccount : simAccount ,
193
+ AccountKeeper : ak ,
194
+ Bankkeeper : bk ,
195
+ ModuleName : types .ModuleName ,
196
+ CoinsSpentInMsg : spendable ,
197
+ }
198
+
199
+ return simulation .GenAndDeliverTxWithRandFees (txCtx )
231
200
}
232
201
}
233
202
@@ -262,26 +231,19 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k
262
231
}
263
232
264
233
msg := types .NewMsgFundCommunityPool (fundAmount , funder .Address )
265
- txGen := simappparams .MakeTestEncodingConfig ().TxConfig
266
- tx , err := helpers .GenTx (
267
- txGen ,
268
- []sdk.Msg {msg },
269
- fees ,
270
- helpers .DefaultGenTxGas ,
271
- chainID ,
272
- []uint64 {account .GetAccountNumber ()},
273
- []uint64 {account .GetSequence ()},
274
- funder .PrivKey ,
275
- )
276
- if err != nil {
277
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to generate mock tx" ), nil , err
278
- }
279
234
280
- _ , _ , err = app .Deliver (txGen .TxEncoder (), tx )
281
- if err != nil {
282
- return simtypes .NoOpMsg (types .ModuleName , msg .Type (), "unable to deliver tx" ), nil , err
235
+ txCtx := simulation.OperationInput {
236
+ App : app ,
237
+ TxGen : simappparams .MakeTestEncodingConfig ().TxConfig ,
238
+ Cdc : nil ,
239
+ Msg : msg ,
240
+ MsgType : msg .Type (),
241
+ Context : ctx ,
242
+ SimAccount : funder ,
243
+ AccountKeeper : ak ,
244
+ ModuleName : types .ModuleName ,
283
245
}
284
246
285
- return simtypes . NewOperationMsg ( msg , true , "" , nil ), nil , nil
247
+ return simulation . GenAndDeliverTx ( txCtx , fees )
286
248
}
287
249
}
0 commit comments